Linux install MySQL

http://blog.csdn.net/wb96a1007/article/details/51559741


View the number of mysql connections
netstat -an | grep 8080|wc -l

export
./mysqldump -uroot -proot db_yy_recover > ./db_yy_recover.sql

copy
scp ./db_account.sql [email protected]:/var/lib/mysql

recover
mysql -uroot -proot;
mysql -u root -p db_account < db_account.sql

create database
 create database db_yy_recover charset utf8;

 Update database character set
alter database db_message charset utf8mb4;

Install MySQL 5.7.9 (install user root, target directory /opt/mysql)

1 View installation
rpm -qa | grep mysql

2 Uninstall
rpm -e mysql-libs-5.1.73-7.el6.x86_64 --nodeps

3 Installation
bin/mysql_install_db --user=mysql --basedir=/opt/mysql/ --datadir=/opt/mysql/data/

4 Copy the configuration file
[root@localhost mysql]# cp -a ./support-files/my-default.cnf /etc/my.cnf
[root@localhost mysql]# cp -a ./support-files/mysql.server  /etc/init.d/mysqld

5 Modify the configuration file
If you change the default installation path, you need to
1) Modify in /etc/my.cnf, /etc/init.d/mysqld
basedir='/apps/mysql'
datadir='/apps/mysql/data'
2) Create ln
mkdir -p /usr/local/mysql/bin
ln -s /apps/mysql/bin/mysqld /usr/local/mysql/bin/mysqld

6 Start
cd /opt/mysql/bin
./mysqld_safe --user=mysql &

/etc/init.d/mysqld restart

set startup
chkconfig --level 35 mysqld on

View initial password
cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2016-12-28 09:31:17
;c2Yhshz6l7>

reset Password
./mysql -uroot -p

mysql>SET PASSWORD = PASSWORD('123456');

mysql>flush privileges;

mysql>use mysql;

mysql>update user set host = '%' where user = 'root';

mysql>select host, user from user;

mysql>flush privileges;

mysql>quit;

Restart MySQL
/etc/init.d/mysqld restart

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326444014&siteId=291194637