redhat6.3安裝MySQL-server-5.6.13-1.el6.x86_64.rpmmysql
首先下載下面三個文件:sql
MySQL-client-5.6.13-1.el6.x86_64.rpm 數據庫
MySQL-devel-5.6.13-1.el6.x86_64.rpm dom
MySQL-server-5.6.13-1.el6.x86_64.rpm socket
-----自注-----------ui
以上三個軟件下載地址:spa
http://pan.baidu.com/s/1qXDnSUK.net
http://pan.baidu.com/s/1qY8KwQ4命令行
http://pan.baidu.com/s/1hrKVLfIrest
而後使用root帳號登錄,進行安裝:
1. 安裝server、devel、client:1. 安裝server、devel、client:
rpm -ivh --replacefiles MySQL-s*.rpm
rpm -ivh --replacefiles MySQL-d*.rpm
rpm -ivh --replacefiles MySQL-c*.rpm
[root@localhost download]# rpm -ivh --replacefiles MySQL-server-5.6.13-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
[root@localhost download]# rpm -ivh --replacefiles MySQL-client-5.6.13-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@localhost download]# rpm -ivh --replacefiles MySQL-devel-5.6.13-1.el6.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-devel ########################################### [100%]
要移除安裝能夠使用 rpm -e MySQL-server 、 rpm -e MySQL-devel、MySQL-client便可;
2. 初始化數據庫:
/usr/bin/mysql_install_db
3. 啓動mysql服務:
service mysql start
-----------自注:---------------------------------------
若是出現:Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).賦予目錄執行權限/var/lib/mysql。
chmod 777 -R /var/lib/mysql
使用命令ps -ef | grep mysql 查看mysql進程:
[root@localhost ~]# ps -ef | grep mysql
root 26047 1 0 18:14 pts/12 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid
mysql 26227 26047 0 18:14 pts/12 00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/lib/mysql/localhost.localdomain.pid --socket=/var/lib/mysql/mysql.sock
root 26545 24726 0 18:27 pts/8 00:00:00 grep mysql
4.第一次登錄設置root密碼:
==========================================================================
自注:
第一次登錄mysql,設置密碼:
1.mysql,回車
2.mysql>use mysql;
3.mysql> update user set password=password('root') where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
4.重啓mysql服務。service mysql restart
5.就能夠登錄mysql。mysql -uroot -p
=================================================================================
首先查看 cat /root/.mysql_secret
root@localhost ~]# cat /root/.mysql_secret
# The random password set for the root user at Fri Aug 30 15:57:18 2013 (local time): fMYcarvB
而後命令行:mysql -u root -p ,而後輸入上面的密碼便可:
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.13 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
設置root密碼:
mysql> use mysql
Database changed
mysql> update user set password=password('root') where user='root';
Query OK, 0 rows affected (0.15 sec)
Rows matched: 5 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
退出,從新登錄便可使用新的密碼登錄;
5. 設置遠程登錄:
使用root登錄到mysql後
mysql> update user set host='%' where user='root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
mysql> select host,user from user;
+-----------------------+------+
| host | user |
+-----------------------+------+
| % | root |
| 127.0.0.1 | root |
| 192.168.128.142 | root |
| ::1 | root |
| localhost.localdomain | root |
+-----------------------+------+
rows in set (0.00 sec)
而後:
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected (0.08 sec)
mysql> exit
Bye
[root@localhost ~]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
重啓mysql便可遠程登錄。
service mysql start出錯,mysql啓動不了,解決mysql: unrecognized service錯誤
service mysql start出錯,mysql啓動不了,解決mysql: unrecognized service錯誤的方法以下:
[root@ctohome.com ~]# service mysql start
mysql: unrecognized service
[root@ctohome.com ~]# service mysql restart
mysql: unrecognized service
[root@ctohome.com ~]# rpm -q mysql 查詢發現mysql已經正常安裝
mysql-5.1.52-jason.1
[root@ctohome.com ~]# /etc/rc.d/init.d/mysqld start 直接啓動沒問題
Starting mysqld: [ OK ]
[root@ctohome.com ~]# ls /etc/rc.d/init.d/mysqld -l
-rwxr-xr-x 1 root root 5509 Dec 18 02:31 /etc/rc.d/init.d/mysqld
[root@ctohome.com ~]# chkconfig mysqld on 設置mysql開機啓動
[root@ctohome.com ~]# chmod 755 /etc/rc.d/init.d/mysqld 修改mysqld執行權限
[root@ctohome.com ~]# service mysqld start 搞定 Starting mysqld: [ OK ] [root@ctohome.com ~]# service mysqld start Starting mysqld: [ OK ] [root@ctohome.com ~]# service mysqld status mysqld (pid 9487) is running...