CentOS 下mysql 的安装
1、安装mysql服务器
yum -y install mysql-server
2、装入service启动服务
/etc/rc.d/init.d/mysqld start
3、设置mysql服务开机自启动
chkconfig mysqld on
如果不确定是否已设置成开机自启动,可通过如下命令查看
chkconfig --list mysqld
(mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off) ← 如果2--5为on的状态就OK
4、查看当前mysql版本信息
mysql –version
5、修改mysql默认编码
vi /etc/my.cnf
在[client]下增加:
default-character-set=utf8
在[mysqld]下增加:
character-set-server = utf8
init_connect='set names utf8'
进入mysql中查看当前编码
mysql>show variables like '%character%';
6、设置访问权限和密码
mysql> grant all privileges on *.* to
'root'@'%' identified by '123';
mysql> grant all privileges on *.* to
'root'@'localhost' identified by '123';
mysql> flush privileges;
可通过以下代码查看当前已经设置的访问权限状态
select * from mysql.user;
7、重启mysql服务
/etc/init.d/mysqld restart
8、彻底卸载mysql
yum remove mysql mysql-server mysql-libs compat-mysql51
rm -rf /var/lib/mysql
rm /etc/my.cnf
查看是否还有mysql软件
rpm -qa|grep mysql //有的话继续删除
rpm -ql mysql //查看文件位置
9.开启远程访问
grant all on user.* to 'user'@'%' identified by 'password';