官网命令如下:
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files
shell> bin/mysqld --initialize --user=mysql
shell> bin/mysql_ssl_rsa_setup
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
一:下载并解压
mysql官网下载连接:https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz这个可以直接下载。如果不行的话去https://dev.mysql.com/downloads/mysql/ 这个网站找。下载好后通过tar -zxvf MySQL文件名字解压。其中z代表显示文件具有gzip属性,x代表解压,v代表显示所有过程,f代表档案名字。其中,f必须在名字参数的最后。f后面加需要解压的文件名字。比如: tar -zxvf mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz。然后通过mv命令修改下文件夹名字,因为太长了,比如改为mysql5.7。
二:安装连接初始化
2.1仍在第一步的目录位置,执行以下命令。
ln -s /usr/local/mysql5.7 mysql
其中/usr/local/mysql5.7 是修改后的文件夹目录。
2.2 进入mysql5.7文件夹;
cd mysql5.7
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-files
bin/mysqld --initialize --user=mysql
bin/mysql_ssl_rsa_setup
bin/mysqld_safe --user=mysql &
# Next command is optionalshell> cp support-files/mysql.server /etc/init.d/mysql.server
官网安装的链接如下:
https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
也可以设置到系统启动。
其中可能有几个坑和错误。
1:mysql5.7中,user表中没有password字段!!!假如想更新密码必须这样:update mysql.user set authentication_string=password('root') where user='root';
2:默认的,通过mysqld启动后,mysql是需要密码的。但是又不知道密码。只能通过安全模式启动。safe_mysqld --skip-grant-tables &。但是还有个问题,如果是登陆的root账户。这样是启动不了的。必须使用非root账户启动mysqld。比如用mysql账号。
safe_mysqld --user=mysql --skip-grant-tables & 上面这个就能启动。然后通过错误1的更新下密码。然后就可以登陆了。如果,你在执行的最上面的命令后能够直接登陆mysql就不需要再执行这2步了,就直接修改root密码了。
3.成功登陆mysql后必须先修改下密码,因为第一次。必须设置密码!。
flush privileges; 刷新
创建用户:create user 'test'@'%' identified by '123456'; 即可远程登陆。
假如忘记了mysql密码,请查看http://www.jb51.net/article/100766.htm。这里面可以解决。我用的是方法2。
如果错误:[ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
:https://www.cnblogs.com/abclife/p/5052997.html
如果错误:
bin/mysqld: error while loading shared libraries: libnuma.so.1: centos7安装mysql5.7
按照mysql出现这个错误:bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
这是缺少
numactl。
这个时候如果是Centos就
yum -y install numactl
就可以解决这个问题了.
ubuntu的就
sudo apt-get install numactl
就可以解决这个问题了。