Centos(64位)下安装配置MySQL

完全卸载之前的安装

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)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值