centos7升级mariadb
centos7升级mariadb
1、备份原数据库
mysqldump -uroot -p --database database_name >name.dump
2、停止服务运行
systemctl stop mariadb && systemctl status mariadb
3、卸载mariadb
yum remove -y mariadb &&yum remove -y mariadb-*
4、查找安装信息并删除
yun list installed |grep mariadb rpm -qa |grep mariadb find / -name mysql find / -name mariadb 删除配置文件:rm -f /etc/my.cnf 删除数据目录:rm -rf /var/lib/mysql
5、添加国内yum源
vim /etc/yum.repos.d/Mariadb.repo
添加以下内容:
[mariadb] name = MariaDB baseurl=https://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64 gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1
官方yum源(国内安装较慢)
http://downloads.mariadb.org/mariadb/repositories/
[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.2/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
6、清除yum源缓存数据,并生成新的yum源数据缓存
yum clean all && yum makecache all
查看下载缓存信息:ll /var/cache/yum/x86_64/7/mariadb
7、安装mariadb
yum install MariaDB-server MariaDB-client -y
启动并添加开机自启:
systemctl start mariadb
systemctl enable mariadb
8、mariadb初始化
mysql_secure_installation
一般建议按以下进行配置:
Enter current password for root (enter for none): Just press the Enter button Set root password? [Y/n]: Y New password: your-MariaDB-root-password Re-enter new password: your-MariaDB-root-password Remove anonymous users? [Y/n]: Y Disallow root login remotely? [Y/n]: n Remove test database and access to it? [Y/n]: Y Reload privilege tables now? [Y/n]: Y
9、导入数据到新版本mariadb
方法一:
登陆mysql后用source命令:(后面跟的是我们备份的sql文件的路径)
source /root/backup/java_api.sql
方法二:
在命令行直接导入
mysql -uroot -p >/root/backup/java_api.sql
以上就是整个版本升级的过程了。
参考其他文章: