MySQL-5.1.71升级MySQL-5.7.21(二进制版本)
指尖二进制 • 1 年前 • 698 次点击 • MYSQL
备份数据库
[root@bs home]# mysqldump -uroot -p datebase > datebase.sql
上传mysql-5.7.21软件包、解压
重命名
[root@bs home]# mv mysql-5.7.21-linux-glibc2.12-x86_64 mysql-5.7.21
授权给mysql用户
[root@bs home]# chown -R mysql.mysql mysql-5.7.21
删除卸载原来的mysql-5.1.17
停止数据库:
[root@bs home]# service mysqld stop
卸载数据库:
[root@bs home]# rpm -qa|grep mysql|xargs rpm -e --nodeps
删除文件:
[root@bs home]# rm -rf /var/lib/mysql
在mysql5.7.21下新建my.cnf配置文件
[root@bs mysql5.7.21]# vim my.cnf
[mysqld]
innodb_buffer_pool_size = 1024M
max_connections=300
innodb_flush_log_at_trx_commit=5
lower_case_table_names=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
将my.cnf 授权给mysql用户、用户组
[root@bs mysql-5.7.21]# chown -R mysql.mysql my.cnf
在/mysql5.7.21/下新建data目录
[root@bs mysql-5.7.21]# mkdir -p /home/mysql-5.7.21/data
授权
[root@bs mysql-5.7.21]# chown -R mysql.mysql data/
然后执行初始化操作
[root@bs mysql-5.7.21]# ./bin/mysqld --initialize-insecure --user=mysql --basedir=/home/mysql-5.7.21 --datadir=/home/mysql-5.7.21/data/
2018-05-23T15:22:09.382906Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-23T15:22:09.686900Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-05-23T15:22:09.732613Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-05-23T15:22:09.796579Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 0f83b22c-5e9d-11e8-9118-000c296955fa.
2018-05-23T15:22:09.797687Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-05-23T15:22:09.798121Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@bs mysql-5.7.21]# ./bin/mysql_ssl_rsa_setup --user=mysql --basedir=/home/mysql-5.7.21 --datadir=/home/mysql-5.7.21/data/
Generating a 2048 bit RSA private key
.................................................................................................................+++
..........................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
..........................................................+++
................................................................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
..............................................................+++
.+++
writing new private key to 'client-key.pem'
-----
配置启动脚本
[root@bs bin]# cp ../support-files/mysql.server /etc/init.d/mysqld
修改参数
[root@bs bin]# vim /etc/init.d/mysqld
basedir=/home/mysql-5.7.21
datadir=/home/mysql-5.7.21/data/
启动5.7.21数据库并查看进程
service mysqld start
ps -ef|grep mysqld
导入数据
在mysql5.7.21/bin下执行 ./mysql -S /tmp/mysql.sock
[root@bs bin]# ./mysql -S /tmp/mysql.sock
设置密码、创建ipm库
mysql> use mysql;
mysql> update user set authentication_string=password('123456') where user = 'root';
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
mysql> flush privileges;
mysql> create database ipm;
导入数据
注意:ipm.sql要写明绝对路径
./mysql -S /tmp/mysql.sock -uroot -p ipm </home/ipm.sql
登陆——进库——查看——OK
[root@bs bin]# ./mysql -uroot -p123456
mysql> show databases;
mysql> use ipm
mysql> show tables;
过程中报错
(二进制版本)mysql-5.7.21初始化提示报错
[root@bs bin]# ./mysqld --initialize-insecure --user=mysql --basedir=/home/mysql-5.7.21/ --datadir=/home/mysql-5.7.21/data/
./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
如果安装mysql出现了以上的报错信息.这是却少numactl这个时候如果是rhel-6.5\6.8就
yum -y install numactl就可以解决这个问题了