阿里云服务器配置MySql
第一步打开终端:登录阿里云服务器
sudo -i
ssh root@8.121.97.122
检查 MySQL
rpm -qa | grep mysql
删除 rpm -e --nodeps xxxxxxx(具体名称)
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql/mysql
rm -rf /var/log/mysql
rm -f /etc/my.cnf
rm -f /usr/my.cnf
1.下载mysql-5.7.25-el7-x86_64.tar.gz
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.25-el7-x86_64.tar.gz
下载成功
正在连接 cdn.mysql.com (cdn.mysql.com)|23.40.193.17|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:713660830 (681M) [application/x-tar-gz]
正在保存至: “mysql-5.7.25-el7-x86_64.tar.gz”
mysql-5.7.25-el7-x8 100%[===================>] 680.60M 2.16MB/s 用时 4m 37s
2021-01-05 15:36:25 (2.46 MB/s) - 已保存 “mysql-5.7.25-el7-x86_64.tar.gz” [713660830/713660830])
2.解压 tar -zxvf mysql-5.7.25-el7-x86_64.tar.gz
tar -zxvf mysql-5.7.25-el7-x86_64.tar.gz
3.常见对应的目录
cd /usr/local/mysql5.7/
mkdir /usr/local/mysql5.7/data
mkdir /usr/local/mysql5.7/log
touch /usr/local/mysql5.7/log/mysqld.log
chown -R mysql /usr/local/mysql5.7/
chgrp -R mysql /usr/local/mysql5.7/
cd /usr/local/mysql5.7/
/usr/local/mysql5.7/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql5.7/ --datadir=/usr/local/mysql5.7/data/
4.配置文件
vi /etc/profile
source /etc/profile
cat /root/.mysql_secret
5.登录 mysql
grep 'temporary password' /var/log/mysqld.log
A temporary password is generated for root@localhost: n(jPp4l-C33#
mysql -uroot -p
password:n(jPp4l-C33#
6.登陆成功:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.25
Copyright (c) 2000, 2019, 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> set PASSWORD = PASSWORD('-20201126Root-');
Query OK, 0 rows affected, 1 warning (0.00 sec)
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> select host,user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
3 rows in set (0.00 sec)
7.配置可远程登录的密码
mysql>GRANT ALL ON *.* TO root@'%' IDENTIFIED BY ‘-20201126Root-' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)
8.到此就可以使用sequel-pro连接远程数据库了
host: 127.0.0.1
username:root 一般是root
password:11223344 这个地方是你重新设置的密码
port:3306