1.下載Server和client
Server:
- wget http://mysql.easynet.be/Downloads/MySQL-5.5/MySQL-server-5.5.25-1.rhel5.x86_64.rpm
Client:
- wget http://mysql.easynet.be/Downloads/MySQL-5.5/MySQL-client-5.5.25-1.rhel5.x86_64.rpm
2.安裝server和client
安裝Server
- [root@inc-platform-dev-153-135 mysql]# rpm -ivh MySQL-server-4.0.16-0.i386.rpm
- error: open of MySQL-server-4.0.16-0.i386.rpm failed: No such file or directory
- [root@inc-platform-dev-153-135 mysql]# rpm -ivh MySQL-server-5.5.25-1.rhel5.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 inc-platform-dev-153-135.hst.bjc.kfc.alidc.net 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 with the /usr/bin/mysqlbug script!
啓動Server
- [root@inc-platform-dev-153-135 mysql]# service mysql start
- Starting MySQL.. [ OK ]
- [root@inc-platform-dev-153-135 mysql]# netstat -an|grep 3306
- tcp 0 0 0.0.0.0:3306 0.0.0.0:* LIST
安裝Client
- [root@inc-platform-dev-153-135 mysql]# rpm -ivh MySQL-client-5.5.25-1.rhel5.x86_64.rpm
- Preparing... ########################################### [100%]
- 1:MySQL-client ########################################### [100%]
3.修改mysql的root用戶密碼
- [root@inc-platform-dev-153-135 mysql]# /usr/bin/mysqladmin -u root password \'javaman\'
3.登錄MySql
登錄:
- [root@inc-platform-dev-153-135 mysql]# mysql -u root -p javaman
- Enter password:
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
無法登錄要修改配置:
- [root@inc-platform-dev-153-135 mysql]# service mysql stop
- Shutting down MySQL. [ OK ]
- [root@inc-platform-dev-153-135 mysql]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
- [1] 23797
- [root@inc-platform-dev-153-135 mysql]# 120603 13:18:12 mysqld_safe Logging to '/var/lib/mysql/inc-platform-dev-153-135.hst.bjc.kfc.alidc.net.err'.
- 120603 13:18:12 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
- [root@inc-platform-dev-153-135 mysql]# mysql -u root mysql
- Reading table information for completion of table and column names
- You can turn off this feature to get a quicker startup with -A
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 1
- Server version: 5.5.25 MySQL Community Server (GPL)
- Copyright (c) 2000, 2011, 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> UPDATE user SET Password=PASSWORD('javaman') where USER='root';
- Query OK, 4 rows affected (0.01 sec)
- Rows matched: 4 Changed: 4 Warnings: 0
- mysql> flush privileges;
- Query OK, 0 rows affected (0.00 sec)
-
- mysql> quit
- Bye
- [root@inc-platform-dev-153-135 mysql]# services mysql restart
- -bash: services: command not found
- [root@inc-platform-dev-153-135 mysql]# service mysql restart
- Shutting down MySQL.120603 13:20:26 mysqld_safe mysqld from pid file /var/lib/mysql/inc-platform-dev-153-135.hst.bjc.kfc.alidc.net.pid ended
- [ OK ]
- Starting MySQL.. [ OK ]
- [1]+ Done mysqld_safe --user=mysql --skip-grant-tables --skip-networking
重新登錄
- [root@inc-platform-dev-153-135 mysql]# mysql -uroot -pjavaman mysql
- Reading table information for completion of table and column names
- You can turn off this feature to get a quicker startup with -A
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 1
- Server version: 5.5.25 MySQL Community Server (GPL)
- Copyright (c) 2000, 2011, 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> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | mysql |
- | performance_schema |
- | test |
- +--------------------+
- 4 rows in set (0.00 sec)
- mysql>
成功了.
4.遠程登錄
當企圖遠程登錄mysql時候,有可能報錯“Host'xxx.xxx.xxx.xx' is not allowed to connect to this MySQL server".在MySql Server 本機修改如下:
- mysql> UPDATE user SET user='root' where host='localhost';
- mysql> update user set host = '%' where user = 'root';
- mysql> select host, user from user;
- +------------------------------------------------+------+
- | host | user |
- +------------------------------------------------+------+
- | % | root |
- | 127.0.0.1 | root |
- | ::1 | root |
- | inc-platform-dev-153-135.hst.bjc.kfc.alidc.net | |
- | inc-platform-dev-153-135.hst.bjc.kfc.alidc.net | root |
- | localhost | root |
- +------------------------------------------------+------+
- 6 rows in set (0.00 sec)