準備環境:html
RedHat 5系統、MySQL 5.6 rpm包node
首先 上傳mysql至服務器mysql
一、 解壓縮MySqllinux
[root@localhost]# tar -xvf MySQL-5.6.2_m5-1.rhel5.i386.tarweb
MySQL-client-5.6.2_m5-1.rhel5.i386.rpmsql
MySQL-devel-5.6.2_m5-1.rhel5.i386.rpm數據庫
MySQL-embedded-5.6.2_m5-1.rhel5.i386.rpm服務器
MySQL-server-5.6.2_m5-1.rhel5.i386.rpmsocket
MySQL-shared-5.6.2_m5-1.rhel5.i386.rpmide
MySQL-test-5.6.2_m5-1.rhel5.i386.rpm
二、 安裝MySQL-server包
[root@localhost]# rpm -ivh MySQL-server-5.6.2_m5-1.rhel5.i386.rpm
error:Failed dependencies:
MySQL conflicts with mysql-5.0.45-7.el5.i386
MySQL-serverconflicts with mysql-server-5.0.45-7.el5.i386
(安裝失敗,因爲系統先前安裝有mysql,把它卸載掉!再安裝)
[root@localhost]# rpm -e mysql-5.0.45-7.el5.i386 --nodeps
[root@localhost]# rpm -e mysql-server-5.0.45-7.el5.i386 –nodeps
[root@localhost]# rpm -ivh MySQL-server-5.6.2_m5-1.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-server ###########################################[100%]
[root@localhost]# rpm -ivh MySQL-client-5.6.2_m5-1.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
三、 啓動mysql並設置登陸密碼
[root@localhost]# /etc/init.d/mysql start
StartingMySQL......[ OK ]
[root@localhost]# mysqladmin -u rootpassword "123456"
四、 登陸mysql並建立數據庫
[root@localhost]# mysql -u root -p
Enterpassword:
Welcometo the MySQL monitor. Commands end with; or \g.
YourMySQL connection id is 5
Serverversion: 5.6.2-m5 MySQL Community Server (GPL)
Copyright(c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracleis 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>create database shiyue;
QueryOK, 1 row affected (0.01 sec)
五、 配置客戶端鏈接
mysql>use mysql;
Readingtable information for completion of table and column names
Youcan turn off this feature to get a quicker startup with -A
Database changed
mysql>grant all on *.* to root@"%" identified by "123456";
QueryOK, 0 rows affected (0.00 sec)
經過對1042問題代碼的查詢,得出編輯/etc/my.cnf文件,在[mysqld]內添加一行skip-name-resolve
在/etc/目錄下如沒有my.cnf配置文件,則請到/usr/share/mysql/下找到*.cnf文件,拷貝其中的一個到/etc/並更名爲my.cnf
[root@localhost]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
[root@localhost]# vi /etc/my.cnf
#Example MySQL config file for medium systems.
#
# Thisis for a system with little memory (32M - 64M) where MySQL plays
# animportant part, or systems up to 128M where MySQL is used together with
#other programs (such as a web server)
#
#MySQL programs look for option files in a set of
#locations which depend on the deployment platform.
# Youcan copy this option file to one of those
#locations. For information about these locations, see:
#http://dev.mysql.com/doc/mysql/en/option-files.html
#
# Inthis file, you can use all long options that a program supports.
# Ifyou want to know which options a program supports, run the program
# withthe "--help" option.
# Thefollowing options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
# Herefollows entries for some specific programs
# TheMySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-external-locking
key_buffer_size= 16M
max_allowed_packet= 1M
table_open_cache= 64
sort_buffer_size= 512K
net_buffer_length= 8K
read_buffer_size= 256K
read_rnd_buffer_size= 512K
myisam_sort_buffer_size= 8M
skip-name-resolve
#Don't listen on a TCP/IP port at all. This can be a security enhancement,
# ifall processes that need to connect to mysqld run on the same host.
# Allinteraction with mysqld must be made via Unix sockets or named pipes.
"/etc/my.cnf"145L, 4700C written