一、下载安装
sudo apt-get install mysql-server
二、初始化配置
查看密码:sudo more /etc/mysql/debian.cnf
连接:mysql -uroot -h 127.0.0.1 -p
修改初始密码:
use mysql;
update mysql.user set authentication_string=password(‘Robots2..‘) where user=‘root‘;
update user set plugin="mysql_native_password";
flush privileges;
quit;
sudo service mysql restart
设置可以远程访问:
use mysql;
update user set host="%" where user="root";
flush privileges;
quit;
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
注释bind-address = 127.0.0.1后重启
sudo service mysql restart
设置显示汉字:(不能显示汉字就是因为character_set_database 的Value值为latin1)
sudo vim /etc/mysql/my.cnf
感叹号上面添加如下内容:
[client]
default-character-set=utf8
[mysqld]
default-storage-engine=INNODB
character-set-server=utf8
collation-server=utf8_general_ci
重启:sudo service mysql restart
三、mysql运维
2、复制mysql库数据到新服务器
CREATE DATABASE litemall;
show databases;
quit;
导出:mysqldump -uroot --databases litemall -p > ~/litemall.sql
下载:sz litemall.sql
上传新服务器:rz
导入mysql -u root -p litemall < ~/litemall.sql