完全卸载之前的安装
yum remove mysql mysql-server mysql-libs compat-mysql51
rm -rf /var/lib/mysql
rm /etc/my.cnf
查看是否还有mysql软件:
rpm -qa|grep mysql
具体看这个帖子http://blog.csdn.net/rosten/article/details/25096159
源安装
# 下载mysql源安装包
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# 安装mysql源
shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm
# 检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
具体看这个帖子http://blog.csdn.net/xyang81/article/details/51759200
启动 重启 停止
systemctl start mysqld
systemctl restart mysqld
systemctl stop mysqld
设置Mysql开机启动
chkconfig mysqld on
连接mysql数据库
mysql -uroot -p -h192.168.137.10/localhost/127.0.0.1 -P3306
设置密码
use mysql;
update user set password=password('密码') where user='root';
flush privileges;
设置Mysql远程访问
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
设置编码
找到客户端配置[client] 在下面添加
default-character-set=utf8 #默认字符集为utf8
在找到[mysqld] 添加
default-character-set=utf8 #默认字符集为utf8
或者(character_set_server=utf8)
init_connect='SET NAMES utf8' #(设定连接mysql数据库时使用utf8编码,以让mysql数据库为utf8运行)
修改好后,重新启动mysql 即可,重新查询数据库编码可发现编码方式的改变:
mysql> show variables like '%character%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)