一、检查系统是否安装其他版本的 MYSQL 数据
#yum list installed | grep mysql
#yum -y remove mysql-libs.x86_64
二、安装及配置
# wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
# rpm -ivh mysql-community-release-el6-5.noarch.rpm
# yum repolist all | grep mysql
安装 MYSQL 数据库
# yum install mysql-community-server -y
设置为开机启动 (2、3、4 都是 on 代表开机自动启动)
# chkconfig --list | grep mysqld
# chkconfig mysqld on
三、设置远程 root
启动 mysql
# service mysqld start
设置 root 密码
# mysql_secure_installation
登陆 root 账号
# mysql -uroot -p
建立远程 root 用户
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'admin' WITH GRANT OPTION;
mysql> flush privileges;
四、设置 utf- 8 编码
查看 mysql 原本编码:
mysql> show variables like 'character%';
设置编码
# vi /etc/my.cnf
如下 (少补):
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
sql_mode='NO_ENGINE_SUBSTITUTION'
[mysql]
default-character-set = utf8
[mysql.server]
default-character-set = utf8
[mysqld_safe]
default-character-set = utf8
[client]
default-character-set = utf8
重启 mysql
# service mysqld restart
再次查看编码:
# mysql -uroot -p
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)
yum 安装
mysql
yum install mysql mysql-server mysql-devel
完成后,用 /etc/init.d/mysqld start 启动 mysql
启动 mysql 控制台:
mysql
mysql>; USE mysql;
mysql>; UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql>; FLUSH PRIVILEGES;
允许远程登录
mysql -u root -p
Enter Password: <your new password>
mysql>GRANT ALL PRIVILEGES ON *.* TO ' 用户名 '@'%' IDENTIFIED BY ' 密码 ' WITH GRANT OPTION;
完成后就能远程管理 mysql 了。
mysql 服务名字 service mysqld start
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY ' 密码 ' WITH GRANT OPTION;
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。