linux下MySQL5.6安裝記錄

MySQL下載地址:
ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.6/
http://mirrors.sohu.com/mysql/
 
 
1.查看服務器版本:

[root@mysql ~]# cat /etc/redhat-release
CentOS release 6.4 (Final)mysql


[root@mysql ~]#  rpm -qa|grep mysql
mysql-libs-5.1.66-2.el6_3.x86_64
發現有mysql包
 

2.初次安裝:
[root@mysql ~]# cd /mysql
[root@mysql mysql]# ls
lost+found
[root@mysql mysql]# ls
lost+found  MySQL-client-5.5.38-1.linux2.6.x86_64.rpm  MySQL-server-5.5.38-1.linux2.6.x86_64.rpm
[root@mysql mysql]#  rpm -ivh MySQL-server-5.5.38-1.linux2.6.x86_64.rpm
Preparing...                ########################################### [100%]
     file /usr/share/mysql/charsets/README from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/cp1251.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
     file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.5.38-1.linux2.6.x86_64 conflicts with file from package mysql-libs-5.1.66-2.el6_3.x86_64
[root@mysql mysql]#
[root@mysql mysql]#
[root@mysql mysql]#
[root@mysql mysql]# mysql
-bash: mysql: command not found
[root@mysql mysql]# cd /usr/share/mys
-bash: cd: /usr/share/mys: No such file or directory
[root@mysql mysql]# cd /usr/share/mysql/
[root@mysql mysql]# ls
charsets  danish  english   french  greek      italian   korean     norwegian-ny  portuguese  russian  slovak   swedish
czech     dutch   estonian  german  hungarian  japanese  norwegian  polish        romanian    serbian  spanish  ukrainian

發現衝突,問題緣由是安裝操做系統時,選中了默認的mysql。
 
 
3.卸載原始mysql包:
[root@mysql share]#  yum remove mysql-libs
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.66-2.el6_3 will be erased
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-2.2.el6_1.x86_64
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: perl-DBD-MySQL-4.013-3.el6.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-2.2.el6_1.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: perl-DBD-MySQL-4.013-3.el6.x86_64
--> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-2.2.el6_1.x86_64
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be erased
---> Package postfix.x86_64 2:2.6.6-2.2.el6_1 will be erased
--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-7.el6.x86_64
--> Running transaction check
---> Package cronie.x86_64 0:1.4.4-7.el6 will be erased
--> Processing Dependency: cronie = 1.4.4-7.el6 for package: cronie-anacron-1.4.4-7.el6.x86_64
--> Running transaction check
---> Package cronie-anacron.x86_64 0:1.4.4-7.el6 will be erased
--> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch
--> Processing Dependency: /etc/cron.d for package: sysstat-9.0.4-20.el6.x86_64
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package crontabs.noarch 0:1.10-33.el6 will be erased
---> Package sysstat.x86_64 0:9.0.4-20.el6 will be erased
--> Finished Dependency Resolution
base                                                                                                                                                                    | 3.7 kB     00:00    
base/primary_db                                                                                                                                                         | 4.4 MB     00:12    
extras                                                                                                                                                                  | 3.4 kB     00:00    
extras/primary_db                                                                                                                                                       |  19 kB     00:00    
updates                                                                                                                                                                 | 3.4 kB     00:00    
updates/primary_db                                                                                                                                                      | 3.7 MB     00:01    

Dependencies Resolved

===============================================================================================================================================================================================
Package                                 Arch                            Version                                       Repository                                                         Size
===============================================================================================================================================================================================
Removing:
mysql-libs                              x86_64                          5.1.66-2.el6_3                                @anaconda-CentOS-201303020151.x86_64/6.4                          4.0 M
Removing for dependencies:
cronie                                  x86_64                          1.4.4-7.el6                                   @anaconda-CentOS-201303020151.x86_64/6.4                          166 k
cronie-anacron                          x86_64                          1.4.4-7.el6                                   @anaconda-CentOS-201303020151.x86_64/6.4                           43 k
crontabs                                noarch                          1.10-33.el6                                   @anaconda-CentOS-201303020151.x86_64/6.4                          2.4 k
perl-DBD-MySQL                          x86_64                          4.013-3.el6                                   @anaconda-CentOS-201303020151.x86_64/6.4                          338 k
postfix                                 x86_64                          2:2.6.6-2.2.el6_1                             @anaconda-CentOS-201303020151.x86_64/6.4                          9.7 M
sysstat                                 x86_64                          9.0.4-20.el6                                  @anaconda-CentOS-201303020151.x86_64/6.4                          807 k

Transaction Summary
===============================================================================================================================================================================================
Remove        7 Package(s)

Installed size: 15 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Erasing    : sysstat-9.0.4-20.el6.x86_64                                                                                                                                                 1/7
  Erasing    : cronie-1.4.4-7.el6.x86_64                                                                                                                                                   2/7
  Erasing    : cronie-anacron-1.4.4-7.el6.x86_64                                                                                                                                           3/7
  Erasing    : crontabs-1.10-33.el6.noarch                                                                                                                                                 4/7
  Erasing    : 2:postfix-2.6.6-2.2.el6_1.x86_64                                                                                                                                            5/7
  Erasing    : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                                                                           6/7
  Erasing    : mysql-libs-5.1.66-2.el6_3.x86_64                                                                                                                                            7/7
  Verifying  : 2:postfix-2.6.6-2.2.el6_1.x86_64                                                                                                                                            1/7
  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                                                                           2/7
  Verifying  : cronie-anacron-1.4.4-7.el6.x86_64                                                                                                                                           3/7
  Verifying  : crontabs-1.10-33.el6.noarch                                                                                                                                                 4/7
  Verifying  : sysstat-9.0.4-20.el6.x86_64                                                                                                                                                 5/7
  Verifying  : mysql-libs-5.1.66-2.el6_3.x86_64                                                                                                                                            6/7
  Verifying  : cronie-1.4.4-7.el6.x86_64                                                                                                                                                   7/7

Removed:
  mysql-libs.x86_64 0:5.1.66-2.el6_3                                                                                                                                                          

Dependency Removed:
  cronie.x86_64 0:1.4.4-7.el6        cronie-anacron.x86_64 0:1.4.4-7.el6      crontabs.noarch 0:1.10-33.el6      perl-DBD-MySQL.x86_64 0:4.013-3.el6      postfix.x86_64 2:2.6.6-2.2.el6_1    
  sysstat.x86_64 0:9.0.4-20.el6    

Complete!
 
 
4.再次安裝mysql:
[root@mysql share]# rpm -q mysql
package mysql is not installed
[root@mysql share]# cd /mysql
[root@mysql mysql]# ls
lost+found  MySQL-client-5.5.38-1.linux2.6.x86_64.rpm  MySQL-server-5.5.38-1.linux2.6.x86_64.rpm
[root@mysql mysql]#  rpm -ivh MySQL-server-5.5.38-1.linux2.6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h mysql password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/


5.安裝客戶端:
[root@mysql mysql]# ls
lost+found  MySQL-client-5.5.38-1.linux2.6.x86_64.rpm  MySQL-server-5.5.38-1.linux2.6.x86_64.rpm
[root@mysql mysql]#  rpm -ivh MySQL-client-5.5.38-1.linux2.6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
[root@mysql mysql]# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State     
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:6010              0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:6011              0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:6012              0.0.0.0:*                   LISTEN     
tcp        0      0 218.195.56.164:22           218.195.56.152:3598         ESTABLISHED
tcp        0      0 218.195.56.164:22           218.195.56.152:2456         ESTABLISHED
tcp        0      0 218.195.56.164:22           218.195.56.152:3596         ESTABLISHED
tcp        0      0 218.195.56.164:22           218.195.56.152:3599         ESTABLISHED 
 
 
6.登陸mysql:
[root@mysql mysql]#  mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
---報錯緣由是服務沒有啓動
 
7.啓動mysql服務:
[root@mysql mysql]#  service mysql start
Starting MySQL.. SUCCESS! 
 
 
8.檢查mysql端口:
[root@mysql ~]#  netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State     
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:6010              0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:6011              0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:6012              0.0.0.0:*                   LISTEN     
tcp        0      0 127.0.0.1:6013              0.0.0.0:*                   LISTEN     
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN     
tcp        0      0 218.195.56.164:22           218.195.56.152:3598         ESTABLISHED
tcp        0      0 218.195.56.164:22           218.195.56.152:2456         ESTABLISHED
tcp        0      0 218.195.56.164:22           218.195.56.152:3596         ESTABLISHED
tcp        0     52 218.195.56.164:22           218.195.56.152:3600         ESTABLISHED
tcp        0      0 218.195.56.164:22           218.195.56.152:3599         ESTABLISHED
[root@mysql ~]# 
 
 
9.再次登陸mysql:
[root@mysql mysql]#  mysql        -----此處是沒設置密碼是,默認自動登陸
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.38 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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.

mysql>


----成功登陸,說明數據庫安裝成功。




[root@mysql ~]# ps -ef|grep mysql
root     22161     1  0 09:08 pts/1    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/mysql.pid
mysql    22254 22161  0 09:08 pts/1    00:00:01 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/mysql.err --pid-file=/var/lib/mysql/mysql.pid
root     22275 21793  0 09:08 pts/1    00:00:00 mysql
 
 
10.修改默認的mysql root密碼:
[root@mysql ~]#  /usr/bin/mysqladmin -u root password wisedu
[root@mysql ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
----修改密碼後,登陸報錯,是要求你用root登陸
 

[root@mysql ~]# mysql -u root -p      -----用root登陸(此處root非操做系統root)
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.38 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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.


11.顯示數據庫信息:
mysql>  show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

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>  show tables;----顯示錶
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)

mysql>  select * from user;   ---查詢表內容
相關文章
相關標籤/搜索