1、YUM安装
# yum -y install mysql-server mysql-devel
2、配置
# vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1 ← 找到这一行,在这一行的下面添加新的规则,让MySQL的默认编码为UTF-8
default-character-set = utf8 ← 添加这一行然后在配置文件的文尾加上:
[mysql]
default-character-set = utf8
3、初始数据库,安装完必须的
# cd /usr/bin
# ./mysql_install_db
4、启动MySQL服务
A、设置MySQL服务开机启动
# chkconfig mysqld on
B、确认MySQL自启动(2--5为on的状态就OK)
# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:offC、启动MySQL
# etc/rc.d/init.d/mysqld start
5、创建用户
# mysqladmin -u root password 123456
6、开启远程授权
# mysql -u root -p123456
mysql>use mysql;
mysql>update user set host = '%' where user = 'root';
若报错ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
直接运行
mysql>flush privileges;mysql>select host, user from user;