epcim
10/21/2015 - 8:21 AM

mysql.howto.md

Mysql

Operations

reset db passorwds

mysqladmin -u root -p password ****** -S /var/run/mysql-default/mysqld.sock

If you forgot it:

/etc/init.d/mysql stop
/usr/bin/mysqld_safe --skip-grant-tables &
mysql --user=root mysql

then

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

reseting user password:

mysql> SET PASSWORD FOR 'gitlab'@'localhost' = PASSWORD('*****')

dump db

mysqldump -uUSER -pPASSWORD --quick --single-transaction --create-options --skip-set-charset --default-character-set=latin1 DATABASE > dump.sql

Configuration

encoding

/etc/mysql/my.cnf:

[client]:
default-character-set=utf8

[mysqld]
# MySQL 5.5.3+
character-set-server=utf8
collation-server=utf8_general_ci

MySQL Tutorials

convert character set

SET collation_connection = 'utf8_general_ci' ALTER DATABASE gitlab CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE table CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci