1. yum -y install mysql-server
成功最后提示:
Installed:
mysql-server.i386 0:5.0.77-4.el5_6.6
Dependency Installed:
mysql.i386 0:5.0.77-4.el5_6.6 perl-DBD-MySQL.i386 0:3.0007-2.el5 perl-DBI.i386 0:1.52-2.el5
Complete!
2. vim /etc/my.cnf
old_passwords=1 ← 找到这一行,在这一行的下面添加新的规则,让MySQL的默认编码为UTF-8
default-character-set = utf8 ← 添加这一行
然后在配置文件的文尾填加如下语句:
[mysql]
default-character-set = utf8
3. chkconfig mysqld on 命令配置mysql随系统自启动
4.chkconfig --list mysqld 查看配置结果
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← 如果2--5为on的状态就OK
5. /etc/rc.d/init.d/mysqld start ← 启动MySQL服务
6. mysql -u root ← 用root用户登录MySQL服务器,控制台显示:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution
7. set password for root@localhost=password('在这里填入root密码'); ← 设置root密码
Query OK, 0 rows affected (0.01 sec)
set password for root@cloud=password('在这里填入root密码'); ← 设置root密码
Query OK, 0 rows affected (0.01 sec)
set password for root@127.0.0.1=password('在这里填入root密码'); ← 设置root密码
Query OK, 0 rows affected (0.01 sec)
8. select user,host,password from mysql.user; ← 查看用户信息
+------+-----------+------------------+
| user | host | password |
+------+-----------+------------------+
| root | localhost | 435e5b2459c49408 |
| root | cloud | 435e5b2459c49408 |
| root | 127.0.0.1 | 435e5b2459c49408 |
| | localhost | |
| | cloud | |
+------+-----------+------------------+
5 rows in set (0.00 sec
9. mysql> delete from mysql.user where user=''; ← 删除匿名用户
Query OK, 2 rows affected (0.17 sec)
10. exit ← 退出MySQL服务器
11. mysql -u root ← 通过空密码用root登录
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) ← 出现此错误信息说明密码设置成功
12. mysql -u root -p ← 通过密码用root登录
Enter password: ← 在这里输入密码
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.77 Source distribution
结束
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。