1.查找已經安裝的文件node
[root@localhost ~]# rpm -qa | grep -i mysql mysql-libs-5.1.66-2.el6_3.x86_64
2.刪除mysql
#rpm -e --nodeps mysql-libs-5.1.61-4.el6.x86_64
3.安裝RPM文件linux
#rpm -ivh MySQL-server-xxx.el6.x86_64.rpm #rpm -ivh MySQL-client-xxx-1.el6.x86_64.rpm #rpm -ivh MySQL-devel-xxx-1.el6.x86_64.rpm
4.修改配置文件位置
sql
# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
5.初使化MYSQL及配置密碼shell
# /usr/bin/mysql_install_db # service mysql start # cat /root/.mysql_secret #查看root帳號密碼 # The random password set for the root user at Wed Dec 11 23:32:50 2013 (local time): qKTaFZnl # mysql -uroot –pqKTaFZnl mysql> SET PASSWORD = PASSWORD('123456'); #設置密碼爲123456 mysql> exit # mysql -uroot -p123456
6.設置容許遠程登陸服務器
mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select host,user,password from user; +-----------------------+------+-------------------------------------------+ | host | user | password | +-----------------------+------+-------------------------------------------+ | localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | | localhost.localdomain | root | *A4B8196FF869F64E0119B231785E5946EDBA5E26 | | 127.0.0.1 | root | *A4B8196FF869F64E0119B231785E5946EDBA5E26 | | ::1 | root | *A4B8196FF869F64E0119B231785E5946EDBA5E26 | +-----------------------+------+-------------------------------------------+ 4 rows in set (0.00 sec) mysql> update user set password=password('root') where user='root'; Query OK, 3 rows affected (0.01 sec) Rows matched: 4 Changed: 3 Warnings: 0 mysql> update user set host='%' where user='root' and host='localhost'; Query OK, 1 row affected (0.04 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
7.設置開機自啓動dom
# chkconfig mysql on # chkconfig --list | grep mysql mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
8.配置字符集ui
配置/etc/my.cnf文件,修改數據存放路徑、mysql.sock路徑以及默認編碼utf-8.this
[client] password = 123456 port = 3306 default-character-set=utf8 [mysqld] port = 3306 character_set_server=utf8 character_set_client=utf8 collation-server=utf8_general_ci #(注意linux下mysql安裝完後是默認:表名區分大小寫,列名不區分大小寫; 0:區分大小寫,1:不區分大小寫) lower_case_table_names=1 #(設置最大鏈接數,默認爲 151,MySQL服務器容許的最大鏈接數16384; ) max_connections=1000 [mysql] default-character-set = utf8
9.查看字符集編碼
show variables like '%collation%'; show variables like '%char%';