centos6.9 卸载mysql_CentOS 6.9卸载MySQL并安装MariaDB的方法

一、卸载MySQL

关闭目前的mysql服务#/etc/init.d/mysqld stop

确保已正常关闭#ps -ef | grep mysql

查询mysql的安装情况:#rpm -qa | grep mysql

将列出来的删除。#rpm -e mysql-server.x86_64

这里有些朋友可能会出错,形如:[root@centos-dev halc]# rpm -e mysql-libs-5.1.69-1.el6_4.i686

error: Failed dependencies:

libmysqlclient.so.16 is needed by (installed) postfix-2:2.6.6-2.2.el6_1.i686

libmysqlclient.so.16(libmysqlclient_16) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.i686

mysql-libs is needed by (installed) postfix-2:2.6.6-2.2.el6_1.i686

用这个就好了#rpm -e --nodeps mysql-libs-5.1.69-1.el6_4.i686

二、安装MariaDB的方法

1.创建/etc/yum.repos.d/MariaDB.repo文件vim /etc/yum.repos.d/MariaDB.repo

#centos 6.9复制下列代码

[mariadb]

name = MariaDB

baseurl = http://mirrors.ustc.edu.cn/mariadb/yum/5.5/centos6-amd64

gpgkey=http://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB

gpgcheck=1

2.准备好repo文件后可以使用yum来安装了# yum install MariaDB-server MariaDB-client

3.自定义数据目录和服务端口,所以移除默认的数据目录(不需要自定义的请直接执行第8步)# rm -rf /var/lib/mysql

4.创建新的数据目录# mkdir /var/data/db/mariadb

5.修改配置文件/etc/my.cnf.d/mysql-clients.cnf,重点是[client],其他的可以参考[client]

port = 3307

socket = /var/data/db/mariadb/mysql.sock

[mysql]

no-auto-rehash

[mysqldump]

quick

max_allowed_packet = 64M

[myisamchk]

key_buffer_size = 128M

sort_buffer_size = 128M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

6.修改配置文件/etc/my.cnf.d/server.cnf,这里的性能参数来自my-large.ini文件[mysqld]

port = 3307

datadir = /var/data/db/mariadb

socket = /var/data/db/mariadb/mysql.sock

skip-external-locking

key_buffer_size = 256M

max_allowed_packet = 64M

table_open_cache = 256

sort_buffer_size = 1M

read_buffer_size = 1M

read_rnd_buffer_size = 4M

myisam_sort_buffer_size = 64M

thread_cache_size = 8

query_cache_size= 16M

thread_concurrency = 8

log-bin=mysql-bin

binlog_format=mixed

server-id = 1

7.初始化数据# mysql_install_db --defaults-file=/etc/my.cnf --datadir=/var/data/db/mariadb/ --user=mysql

8.启动服务# service mysql start

9.设置ROOT密码# mysqladmin -u root password "8888888"

10.登陆mysql# mysql -uroot -p

11.授权root远程登录#root可从任何IP登陆,注意修改密码:'888888'

mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '888888' WITH GRANT OPTION;

#root可从指定IP登陆,注意修改密码:'888888'、IP:'192.168.1.188'

mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.188' IDENTIFIED BY '888888' WITH GRANT OPTION;

mysql>FLUSH PRIVILEGES;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值