linux mysql 4.0 安装_Linux下Mysql安装

1、下载安装包

首先查看Linux版本:

[root@localhost ~]# lsb_release -a

LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch

Distributor ID: RedHatEnterpriseServer

Description: Red Hat Enterprise Linux Server release6.3(Santiago)

Release:6.3Codename: Santiago

结果显示系统为64位Redhat6.3 ,去Mysql官网(http://dev.mysql.com/downloads/mysql#downloads)下载相应的版本。

wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-devel-5.5.36-1.el6.x86_64.rpm

wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-client-5.5.36-1.el6.x86_64.rpm

wget http://cdn.mysql.com/Downloads/MySQL-5.5/MySQL-server-5.5.36-1.el6.x86_64.rpm

2、安装Mysql服务和客户端

rpm -ivh MySQL-server-5.5.36-1.el6.x86_64.rpm

[root@localhost mysql]# rpm -ivh MySQL-server-5.5.36-1.el6.x86_64.rpm

Preparing... ########################################### [100%]1:MySQL-server ########################################### [100%]

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER!Todoso, start the server, then issue the following commands:/usr/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h localhost 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 bydefault. This isstrongly recommendedforproduction servers.

See the manualformore instructions.

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

[root@localhost mysql]# rpm -ivh MySQL-client-5.5.36-1.el6.x86_64.rpm

Preparing... ########################################### [100%]

1:MySQL-client ########################################### [100%]

可能遇到的问题:

1>如果出现类似:

file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.5.36-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64

file/usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.5.36-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64

file/usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.5.36-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64

file/usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.5.36-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64

file/usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.5.36-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64

file/usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.5.36-1.el6.x86_64 conflicts with file from package mysql-libs-5.1.61-4.el6.x86_64

说明有包冲突,这时候要移除冲突的包,使用命令:

yum -y remove mysql-libs-5.1.61*

2>如果移除时出现:

Loaded plugins: product-id, refresh-packagekit, security, subscription-manager

Updating certificate-based repositories.

Unable to read consumer identity

Existinglock /var/run/yum.pid: another copy is running as pid 14110.

说明YUM正在更新,使用命令:

rm -f /var/run/yum.pid

3、服务启动、停止、重新启动

[root@localhost usr]# service mysql start

[root@localhost usr]# service mysql stop

[root@localhost usr]# service mysql restart

4、修改root密码

[root@localhost bin]# mysqladmin -u root -p'root' password 'rockontrol'

5、常见问题

登录出现 Access denied for user 'root'@'localhost' (using password:YES)。解决步骤如下:

a:以root用户登录系统

b:看一下Mysql服务的状态 如果启动则杀掉进程 命令如下

[root@localhost ~]# /etc/init.d/mysql status

ERROR! MySQL isrunning but PID file could not be found

[root@localhost~]# ps aux|grep mysql

root1468 0.0 0.0 115216 1680 ? S 6月16 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/localhost.localdomain.pid

mysql1638 0.0 2.7 1040276 455956 ? Sl 6月16 0:29 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/localhost.localdomain.err --pid-file=/var/lib/mysql/localhost.localdomain.pid

root17015 0.0 0.0 112660 976 pts/0 S+ 08:42 0:00 grep --color=auto mysql

[root@localhost~]# kill 1468[root@localhost~]# kill 1638[root@localhost~]# kill 17015

c:启动特权命令:mysqld_safe --skip-grant-tables &

d:在重新打开一个连接以普通用户命令进去   这时候就不需要在输入密码了

[root@localhost ~]# mysql -u root -p

Enter password:

直接回车就可以进去了   然后修改user表的密码就可以了

mysql>use mysql

Reading table informationforcompletion of table and column names

You can turn offthis feature to get a quicker startup with -A

Database changed

mysql> select host,user,password fromuser;+-----------------------+------+-------------------------------------------+

| host | user | password |

+-----------------------+------+-------------------------------------------+

| localhost | root | *68A463BD53874E39A4D68117C03FB1A777EC9DA9 |

| localhost.localdomain | root | *68A463BD53874E39A4D68117C03FB1A777EC9DA9 |

| 127.0.0.1 | root | *68A463BD53874E39A4D68117C03FB1A777EC9DA9 |

| ::1 | root | *68A463BD53874E39A4D68117C03FB1A777EC9DA9 |

+-----------------------+------+-------------------------------------------+

4 rows in set (0.00sec)

mysql> update user set host='%' where host='localhost';

Query OK,1 row affected (0.00sec)

Rows matched:1 Changed: 1 Warnings: 0mysql> update user set password='';

Query OK,4 rows affected (0.00sec)

Rows matched:4 Changed: 4 Warnings: 0

这样就清空所有的密码了

e:这时候可以退出特权模式 重新启动Mysql服务  然后修改一下密码就可以了

SET PASSWORD=PASSWORD('123456');

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值