MySQL - Linux安装MySql 5.5.45 操作步骤【亲测】

你踩过的坑,终究会成为你进步的动力。

记录一下熬夜安装MySQL的相关步骤

下载

自行百度,版本选择:

MySQL-server-5.5.45-1.linux2.6.x86_64

MySQL-client-5.5.45-1.linux2.6.x86_64

任意一款 ftp工具。

MySQL - Linux安装MySql 5.5.45 操作步骤【亲测】_第1张图片

检查环境

查看是否已经安装相关MySQL:

rpm -qa | grep -i mysql

 卸载 系统原有mysql:

执行 yum 命令,删除 MySQL 的 lib 库,服务文件:

yum remove mysql mysql-server mysql-libs

执行 find 命令,查找 MySQL 的残留文件,然后运行“rm -rf 文件名”删除残留的 MySQL 文件

find / -name mysql

再次 确定删除是否干净

rpm -qa | grep -i mysql

执行完上述命令后,返回空数据,则删除完成。否则,执行下面的命令删除MySQL 的相关包文件。

yum -y remove mysql-libs*

安装MySQL

上传MySQL

我这边本地电脑下载好 相关版本对应的MySQL后,用任一 ftp 工具进行上传到 /usr/local/路径下:

MySQL - Linux安装MySql 5.5.45 操作步骤【亲测】_第2张图片

安装 mysql-server

安装server端

[root@jtxws56k local]# rpm -ivh MySQL-server-5.5.45-1.linux2.6.x86_64.rpm 
warning: MySQL-server-5.5.45-1.linux2.6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MySQL-server-5.5.45-1.linux2.6   ################################# [100%]
190621  0:28:03 [Note] /usr/sbin/mysqld (mysqld 5.5.45) starting as process 2711 ...
190621  0:28:03 [Note] /usr/sbin/mysqld (mysqld 5.5.45) starting as process 2718 ...

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 jtxws56k 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 at http://bugs.mysql.com/

安装client 端

[root@jtxws56k local]# rpm -ivh MySQL-client-5.5.45-1.linux2.6.x86_64.rpm 
warning: MySQL-client-5.5.45-1.linux2.6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:MySQL-client-5.5.45-1.linux2.6   ################################# [100%]

服务相关

尝试启动服务

root@jtxws56k local]# /etc/init.d/mysql start
Starting MySQL... SUCCESS! 

停止服务

[root@jtxws56k local]# /etc/init.d/mysql stop
Shutting down MySQL. SUCCESS! 

使用安全模式登陆,跳过密码验证

[root@jtxws56k /]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[4] 3158
[root@jtxws56k /]# 190621 00:35:32 mysqld_safe Logging to '/var/lib/mysql/jtxws56k.err'.
190621 00:35:32 mysqld_safe A mysqld process already exists

此时不需要密码即可进入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.45 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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('88888888888') where USER='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 4  Changed: 0  Warnings: 0

刷新权限

mysql>  FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
[4]   Exit 1                  mysqld_safe --user=mysql --skip-grant-tables --skip-networking

重启服务

[root@jtxws56k /]# /etc/init.d/mysql restart
Shutting down MySQL.190621 00:39:47 mysqld_safe mysqld from pid file /var/lib/mysql/jtxws56k.pid ended
 SUCCESS! 
Starting MySQL.. SUCCESS! 
[3]   Done                    mysqld_safe --user=mysql --skip-grant-tables --skip-networking

密码登录

[root@jtxws56k /]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.45 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'
    -> IDENTIFIED BY 'abc8888woaini666123' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> QUIT
Bye

设置开机启动

[root@jtxws56k /]# chkconfig mysql on

查看是否加入成功

[root@jtxws56k /]# chkconfig --list

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

jexec          	0:off	1:on	2:on	3:on	4:on	5:on	6:off
mysql          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
netconsole     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
network        	0:off	1:off	2:on	3:on	4:on	5:on	6:off

连接测试MySQL

MySQL - Linux安装MySql 5.5.45 操作步骤【亲测】_第3张图片

 

 

 

好了,晚安;

enjoy。

2019年6月21日02:03:15

 

 

明晚 将 持续搭建 文件服务器Fastdfs......

 

 

 

 

你可能感兴趣的:(MySQL)