linux 安装mysql5.7踩坑

linux卸载mysql(完全卸载)

https://blog.csdn.net/qq_41829904/article/details/92966943
2分钟装好面板,一键管理服务器
https://www.bt.cn/linux.html?invite_code=MV9wcGJuaWI=&sdclkid=AL-pALfz15fGxrDixLf
Centos安装脚本 yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh f72f90

Starting Bt-Panel....    done
Starting Bt-Tasks...     done
username: yfyka2qh
Stopping Bt-Tasks...    done
Stopping Bt-Panel...    done
Starting Bt-Panel....    done
Starting Bt-Tasks...     done
iptables:将防火墙规则保存到 /etc/sysconfig/iptables:     [确定]
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:清除防火墙规则:                                 [确定]
iptables:正在卸载模块:                                   [确定]
iptables:应用防火墙规则:                                 [确定]
iptables:载入额外模块:ip_conntrack_netbios_ns ip_conntrac[确定]ip_nat_ftp 
==================================================================
Congratulations! Installed successfully!
==================================================================
外网面板地址: http://14.127.248.192:8888/2748e291
内网面板地址: http://192.168.142.128:8888/2748e291
username: yfyka2qh
password: 71673e91
If you cannot access the panel,
release the following panel port [8888] in the security group
若无法访问面板,请检查防火墙/安全组是否有放行面板[8888]端口


安装包下载:
https://downloads.mysql.com/archives/community/
 MySQL Product Archives
 MySQL Community Server (Archived Versions)
Please note that these are old versions. New releases will have recent bug fixes and features!
To download the latest release of MySQL Community Server, please visit MySQL Downloads.

Product Version:
5.7.16

Operating System:
Linux - Generic
OS Version:
All
Linux - Generic (glibc 2.5) (x86, 64-bit), Compressed TAR Archive    Sep 28, 2016    611.8M    
Download
(mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz)

问题: mysqld --initialize 没反应 ./mysqld --initialize --console 没反应
1、去掉这个配置

2、删除掉 /usr/local/mysql/data/ 文件夹

3、重新 进入 mysql/bin   执行  【./mysqld --initialize --console】

 如果没有删掉   /usr/local/mysql/data/  会报错

 --initialize specified but the data directory has files in it. Aborting.
————————————————
版权声明:本文为CSDN博主「cy谭」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhan107876/article/details/100706655
https://blog.csdn.net/zhan107876/article/details/100706655

-----------------------------------------------------------

可用安装教程:

https://blog.csdn.net/qq_37598011/article/details/93489404?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control

https://zyqok.blog.csdn.net/article/details/103285472?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-1.control

初始化数据库

[root@localhost local]# cd /usr/local/mysql/bin/
[root@localhost bin]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize
mysqld: [Warning] World-writable config file '/etc/my.cnf' is ignored.
2021-05-23T14:13:40.641377Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-05-23T14:13:41.083483Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-05-23T14:13:41.174268Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-05-23T14:13:41.312888Z 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: 1368d5e5-bbd1-11eb-81f2-000c29cade67.
2021-05-23T14:13:41.315250Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-05-23T14:13:41.333466Z 1 [Note] A temporary password is generated for root@localhost: ,fvu>TTeK5L;
[root@localhost bin]# 

-----
报错
[root@localhost bin]# service mysql start
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
Starting MySQL.my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
my_print_defaults: [Warning] World-writable config file '/etc/my.cnf' is ignored.
/usr/local/mysql/bin/mysqld_safe: line 548: /usr/local/mysql/data/mysqld_safe.pid: No such file or directory
awk: (FILENAME=- FNR=1) warning: error writing standard output (Broken pipe)
touch: cannot touch `/usr/local/mysql/data/localhost.localdomain.err': No such file or directory
chmod: cannot access `/usr/local/mysql/data/localhost.localdomain.err': No such file or directory
touch: cannot touch `/usr/local/mysql/data/localhost.localdomain.err': No such file or directory
chown: cannot access `/usr/local/mysql/data/localhost.localdomain.err': No such file or directory
/usr/local/mysql/bin/mysqld_safe: line 135: /usr/local/mysql/data/localhost.localdomain.err: No such file or directory
/usr/local/mysql/bin/mysqld_safe: line 169: /usr/local/mysql/data/localhost.localdomain.err: No such file or directory
touch: cannot touch `/usr/local/mysql/data/localhost.localdomain.err': No such file or directory
chown: cannot access `/usr/local/mysql/data/localhost.localdomain.err': No such file or directory
chmod: cannot access `/usr/local/mysql/data/localhost.localdomain.err': No such file or directory
/usr/local/mysql/bin/mysqld_safe: line 135: /usr/local/mysql/data/localhost.localdomain.err: No such file or directory
 ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).
[root@localhost bin]# ^C
[root@localhost bin]# 

chmod 777 /etc/my.cnf 会报错

 linux 安装mysql5.7踩坑_第1张图片

解决Warning: World-writable config file ‘/etc/my.cnf’ is ignored

xeay@ubuntu:~$ mysql
Warning: World-writable config file '/etc/mysql/my.cnf' is ignored
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
‘/etc/my.cnf’ is ignored ,大概意思是权限全局可写,任何一个用户都可以写。mysql担心这种文件被其他用户恶意修改,所以忽略掉这个配置文件。导致无法进入,这也是mysql的安全机制之一。所以我们必须得改一些权限。设置其他用户不可写。

shell如下

chmod 644 /etc/my.cnf  不能   chmod 777 /etc/my.cnf   会报错!!!!

然后执行:

service mysql restart 

即可。

修改密码:

   ./mysql -u root -p #bin目录下

  1. SET PASSWORD = PASSWORD('123456');

  2. ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;

  3. FLUSH PRIVILEGES;

linux 安装mysql5.7踩坑_第2张图片

windows 链接错误:

linux 安装mysql5.7踩坑_第3张图片

MySQL之2003-Can't connect to MySQL server on 'localhost'(10038)的解决办法

远程连接mysql root账号报错:2003-can't connect to MYSQL serve - fallstar - 博客园

linux 安装mysql5.7踩坑_第4张图片

不能连接MySQL服务主机3306_解决centos的mysql服务3306端口无法远程连接10038问题

重启 mysql :

linux 安装mysql5.7踩坑_第5张图片

linux 安装mysql5.7踩坑_第6张图片

你可能感兴趣的:(linux,mysql,数据库)