Mysql linux 安装

[quote]Redhat 5 下安装Mysql[/quote]

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
[code="java"]
# 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
# 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!

[/code]
启动Server
[code="java"]
# service mysql start
Starting MySQL.. [ OK ]
# netstat -an|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LIST[/code]
安装Client
[code="java"]
# rpm -ivh MySQL-client-5.5.25-1.rhel5.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[/code]

3.修改mysql的root用户密码
[code="java"]
# /usr/bin/mysqladmin -u root password \'javaman\'
[/code]
3.登录MySql
登录:
[code="java"]
# mysql -u root -p javaman
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[/code]
无法登录要修改配置:
[code="java"]
# service mysql stop
Shutting down MySQL. [ OK ]
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[1] 23797
# 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

# 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)
[code="java"][/code]
mysql> quit
Bye
# services mysql restart
-bash: services: command not found
# 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
[/code]
重新登录
[code="java"]
# 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>


[/code]
成功了.
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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值