目录
第1章Linux下完全卸载mysql2
1.1查找以前是否装有mysql2
1.2停止mysql服务、删除之前安装的mysql2
1.3停止mysql服务、删除之前安装的mysql2
1.4再次查找机器是否安装mysql3
第2章Linux下安装mysql4
2.1下载安装包4
2.2安装mysql包4
2.3初始化数据库4
2.4启动mysql服务4
2.5第一次登录设置root密码4
2.6设置远程登录5
2.7使mysql不区分大小写5
命令:rpm -qa|grep -i mysql
可以看到如下图的所示:
说明之前安装了:
MySQL-client-5.5.25a-1.rhel5
MySQL-server-5.5.25a-1.rhel5
删除命令:rpm -e --nodeps(忽略依赖关系删除) 包名
# rpm -e MySQL-client-5.5.25a-1.rhel5
# rpm -e MySQL-server-5.5.25a-1.rhel5
find / -name mysql
查找结果如下:
[root@localhost ~]# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
删除对应的mysql目录
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql
rm -rf /usr/lib64/mysql
具体的步骤如图:查找目录并删除
注意:卸载后/etc/my.cnf不会删除,需要进行手工删除
rm -rf /etc/my.cnf
rpm -qa|grep -i mysql
无结果,说明已经卸载彻底、接下来直接安装mysql即可
首先下载下面三个文件:
MySQL-client-5.6.13-1.el6.x86_64.rpm
MySQL-devel-5.6.13-1.el6.x86_64.rpm
MySQL-server-5.6.13-1.el6.x86_64.rpm
然后使用root账号登陆,进行安装:
安装server、devel、client:
rpm -ivh --replacefiles MySQL-s*.rpm
rpm -ivh --replacefiles MySQL-d*.rpm
rpm -ivh --replacefiles MySQL-c*.rpm
要移除安装可以使用 rpm -e MySQL-server 、 rpm -e MySQL-devel、MySQL-client即可;
/usr/bin/mysql_install_db
service mysql start
使用命令ps -ef | grep mysql 查看mysql进程
首先查看 cat /root/.mysql_secret
root@localhost ~]# cat /root/.mysql_secret
然后命令行:mysql -u root -p ,然后输入上面的密码即可:
设置root密码:
mysql> use mysql;
Database changed
mysql> update user set password=password('root') where user='root';
Query OK, 0 rows affected (0.15 sec)
Rows matched: 5 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
退出,重新登陆即可使用新的密码登陆;
使用root登陆到mysql后
mysql> update user set host='%' where user='root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
mysql> select host,user from user;
+-----------------------+------+
| host | user |
+-----------------------+------+
| % | root |
| 127.0.0.1 | root |
| 192.168.128.142 | root |
| ::1 | root |
| localhost.localdomain | root |
+-----------------------+------+
5 rows in set (0.00 sec)
然后:
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected (0.08 sec)
mysql> exit
Bye
[root@localhost ~]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
重启mysql即可远程登陆。
my.cnf(/etc/my.cnf)的[mysqld]区段下增加:
lower_case_table_names=1
==========================================================
http://my.oschina.net/lzwenme/blog/291292
1. 下载MySQL 5.6
下载页面:http://dev.mysql.com/downloads/mysql/
此处选择 “Red Hat Enterprise Linux 6 / Oracle Linux 6 (x86, 32-bit), RPM Bundle”下载,下载至/root/Downloads/目录下,下载文件名为“MySQL-5.6.15-1.el6.i686.rpm- bundle.tar”
2. 解压tar包
cd /root/Downloads/
tar -xvf MySQL-5.6.15-1.el6.i686.rpm-bundle.tar
3. 以RPM方式安装MySQL
在RHEL系统中,必须先安装“MySQL-shared-compat-5.6.15-1.el6.i686.rpm”这个兼容包,然后才能安装server和client,否则安装时会出错。
yum install MySQL-shared-compat-5.6.15-1.el6.i686.rpm # RHEL兼容包
yum install MySQL-server-5.6.15-1.el6.i686.rpm # MySQL服务端程序
yum install MySQL-client-5.6.15-1.el6.i686.rpm # MySQL客户端程序
yum install MySQL-devel-5.6.15-1.el6.i686.rpm # MySQL的库和头文件
yum install MySQL-shared-5.6.15-1.el6.i686.rpm # MySQL的共享库
4. 配置MySQL登录密码
cat /root/.mysql_secret # 获取MySQL安装时生成的随机密码
service mysql start # 启动MySQL服务
mysql -uroot -p # 进入MySQL,使用之前获取的随机密码
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password'); # 在MySQL命令行中设置root账户的密码为password
quit # 退出MySQL命令行
service mysql restart # 重新启动MySQL服务