Tags: mysql

Sort by: Date / Title /

  1. 4 years ago by spirit
    1. mysqldump –add-drop-table –extended-insert –force –log-error=error.log -uUSER -pPASS OLD_DB_NAME | ssh -C user@newhost "mysql -uUSER -pPASS NEW_DB_NAME"
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2167"></script>
  2. 4 years ago by sox
    # Enable
    mysql> SET GLOBAL general_log = 'ON';
    
    # On Debian, you can check log on /var/run/mysqld/mysqld.log
    tail -f /var/run/mysqld/mysqld.log
    
    # Disable
    mysql> SET GLOBAL general_log = 'OFF';
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2138"></script>
  3. 6 years ago by sox
    First of all you will need to ensure that your database is stopped:
    
    root@steve:~# /etc/init.d/mysql stop
    
    Now you should start up the database in the background, via the mysqld_safe command:
    
    root@steve:~# /usr/bin/mysqld_safe --skip-grant-tables &
    [1] 6702
    Starting mysqld daemon with databases from /var/lib/mysql
    mysqld_safe[6763]: started
    
    Here you can see the new job (number "1") has started and the server is running with the process ID (PID) of 6702.
    
    Now that the server is running with the --skip-grant-tables flag you can connect to it without a password and complete the job:
    
    root@steve:~$ mysql --user=root mysql
    Enter password:
    
    mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';
    Query OK, 2 rows affected (0.04 sec)
    Rows matched: 2  Changed: 2  Warnings: 0
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.02 sec)
    
    mysql> exit
    Bye
    
    Now that you've done that you just need to stop the server, so that you can go back to running a secure MySQL server with password restrictions in place. First of all bring the server you started into the foreground by typing "fg", then kill it by pressing "Ctrl+c" afterwards.
    
    This will now allow you to start the server:
    
    root@steve:~# /etc/init.d/mysql start
    Starting MySQL database server: mysqld.
    Checking for corrupt, not cleanly closed and upgrade needing tables..
    
    Now everything should be done and you should have regained access to your MySQL database(s); you should verify this by connecting with your new password:
    
    root@steve:~# mysql --user=root --pass=new-password-here
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 5 to server version: 5.0.24a-Debian_4-log
    
    Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
    
    mysql> exit
    Bye
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2126"></script>
  4. sponsorised links
  5. 6 years ago by spirit
    Create a specific user for backups purpose with read-only permissions
    1. GRANT SHOW DATABASES, SELECT, LOCK TABLES, RELOAD ON *.* to backup@localhost IDENTIFIED BY 'password';
    2. FLUSH PRIVILEGES;
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2082"></script>
  6. 6 years ago by macks
    binary
    1. SELECTFROM `table`  WHERE BINARY `COLUMN` = 'value'
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2078"></script>
  7. 6 years ago by macks
    1. SELECT id,title INTO OUTFILE "c:/result.text"
    2. FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    3. LINES TERMINATED BY "n"
    4. FROM property;
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2074"></script>
  8. 7 years ago by spirit
    Il faut avoir un backup de base tel qu'il y ait un dossier par base de donnée, un fichier SQL compressé par table. "-P 4" désigne le nombre de core.
    1. find -print0 | xargs -0 -n 1 -P 4 -I {} sh -c "zcat '{}' | mysql mydatabase"
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2071"></script>
  9. 7 years ago by spirit
    Scripted install of MySQL
    1. echo mysql-server mysql-server/root_password select PASSWORD | debconf-set-selections
    2. echo mysql-server mysql-server/root_password_again select PASSWORD | debconf-set-selections
    3.  
    4. aptitude -y install mysql-server libmysqlclient15-dev
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2060"></script>
  10. 7 years ago by macks
    1. from django.db import load_backend, transaction, connection
    2.  
    3. #manipular datos de una bd externa
    4.  
    5. def sincronizeDB(self):
    6.         myBackend = load_backend('mysql') # or 'mysql', 'sqlite3', 'oracle'
    7.         myConnection = myBackend.DatabaseWrapper({
    8.             'DATABASE_HOST': '192.168.1.11',
    9.             'DATABASE_NAME': 'agenciaperu_local',
    10.             'DATABASE_OPTIONS': {},
    11.             'DATABASE_PASSWORD': "",
    12.             'DATABASE_PORT': "",
    13.             'DATABASE_USER': "root",})
    14.         # Now we can do all the standard raw sql stuff with myConnection.
    15.         myCursor = myConnection.cursor()       
    16.         id = 22
    17.         name = "tecnologia para jos"
    18.         slug = "tecnologia_para_jos"
    19.         row = myCursor.execute("INSERT INTO category(name, slug )  values(%s,%s);", [name, slug])
    20.         row = myConnection._commit()
    21.         #row = transaction.rollback_unless_managed()  -----> sería cuando trabajamos en local
    22.  
    23. # select simple
    24.         #row = myCursor.execute("select *from category where id = %s and highlight = %s;",[id,0])
    25.         myCursor.fetchall()
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2056"></script>
  11. 7 years ago by macks
    1. #terminal
    2. C:\>mysql -uroot -p
    3. mysql> SELECT version();
    4.  
    5. # cliente mysql
    6. SELECT version();
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1787"></script>

First / Previous / Next / Last / Page 1 of 6 (51 posteets)