虚拟机安装MySQL
虚拟机安装mysql1,检查是否安装mariadb,若安装则卸载执行检查命令:rpm -qa | grep mariadbrpm -qa | grep mariadb-server执行卸载命令:rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64(注意:mariadb-libs-5.5.60-1.el7_5.x86_64 版本不一,卸载自己检查出来的
·
虚拟机安装mysql
1,检查是否安装mariadb,若安装则卸载
执行检查命令:
rpm -qa | grep mariadb
rpm -qa | grep mariadb-server
执行卸载命令:
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64 (注意:mariadb-libs-5.5.60-1.el7_5.x86_64 版本不一,卸载自己检查出来的版本)
2,检查是否有mysql
执行命令:whereis mysql
如果有执行命令:rm -rf 对应目录 (比如:rm -rf /usr/local/mysql)
3,检查Mysql用户组和用户是否存在
执行命令:cat /etc/group | grep mysql
执行命令:cat /etc/passwd |grep mysql
如果没有则创建:
执行命令:groupadd mysql
执行命令:useradd -r -g mysql mysql
4,上传mysql 安装包
可以通过ftp 上传:mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
解压:tar -zxvf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
重命名并放到指定位置:mv mysql-5.7.34-linux-glibc2.12-x86_64 /usr/local/mysql
5,更改mysql目录下所有的目录及文件夹所属的用户组和用户,以及权限
[root@localhost local]# chown -R mysql:mysql mysql
[root@localhost local]# ls -al
总用量 0
drwxr-xr-x. 13 root root 144 2月 18 09:25 .
drwxr-xr-x. 13 root root 155 2月 15 19:44 ..
drwxr-xr-x. 2 root root 6 4月 11 2018 bin
drwxr-xr-x. 2 root root 6 4月 11 2018 etc
drwxr-xr-x. 2 root root 6 4月 11 2018 games
drwxr-xr-x. 2 root root 6 4月 11 2018 include
drwxr-xr-x. 2 root root 6 4月 11 2018 lib
drwxr-xr-x. 2 root root 6 4月 11 2018 lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 libexec
drwxr-xr-x. 9 mysql mysql 129 2月 18 09:22 mysql
drwxr-xr-x. 2 root root 6 4月 11 2018 sbin
drwxr-xr-x. 5 root root 49 2月 15 19:44 share
drwxr-xr-x. 2 root root 6 4月 11 2018 src
6,初始化mysql
初始化之前先进入cd /usr/local/mysql/bin,否则会报错
[root@localhost bin]# ./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
2022-02-18T01:38:53.455969Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-02-18T01:38:53.716479Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-02-18T01:38:53.753340Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-02-18T01:38:53.812119Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 87e6df60-905b-11ec-a7fe-000c29db2cdf.
2022-02-18T01:38:53.818241Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-02-18T01:38:54.203509Z 0 [Warning] CA certificate ca.pem is self signed.
2022-02-18T01:38:54.336357Z 1 [Note] A temporary password is generated for root@localhost: 9y(alySpm;Ew
途中 9y(alySpm;Ew 为mysql管理员临时登录密码,请先做保存
7,启动mysql服务
[root@localhost /]# /usr/local/mysql/support-files/mysql.server start
Starting MySQL.Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
SUCCESS!
8,添加软连接,并重启mysql服务
[root@localhost /]# ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[root@localhost /]# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
[root@localhost /]# service mysql restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
9,登录mysql,修改密码
[root@localhost /]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.34
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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> set password for root@localhost = password('123456');
Query OK, 0 rows affected, 1 warning (0.04 sec)
10,开放远程连接
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set user.Host='%' where user.User='root';
Query OK, 1 row affected (0.04 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
mysql> exit
更多推荐
已为社区贡献1条内容
所有评论(0)