终于把mysql装好了,遇到了N多不知问题的坑。
附带原文:
大体步骤:
到mysql官网,找到合适自己的安装包下载下来,也可以直接在linux命令行中用wget命令直接下载,我这里是先在家里下好的。
找到合适自己操作系统的版本即可(注意32位还是64位的),比如我是centos6.5,可以下red hat版的,也可以下linux generic版的。
安装包有好几种,rpm(安装版)、tar.gz(解压版)、源码版(没看到)
最终我下载的是mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz
不扯淡了,来正文:
1.创建组和用户:
groupadd mysql
useradd mysql -r -g msyql mysql
2.把下好的压缩包搞到服务器上去
把压缩包搞到这个目录: /usr/local
解压:
tar zxvf mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz
删除压缩包
rm -rf mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz
重命名为mysql
mv mysql-5.6.29-linux-glibc2.5-x86_64 mysql
进入mysql目录,并初始化msyql数据库
cd /usr/local/mysql
#初始化mysql数据库
scripts/mysql_install_db --user=mysql
#也可以这么初始化
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --ldata=/var/lib/mysql
3.开启mysql
bin/mysqld_safe --user=mysql
4.执行安全机制
#bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERSSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MySQL to secure it, we'll need the current passwordpassword for the root user. If you've just installed MySQL, andyou haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current passwordyou haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):<---输入现在的root密码,因为我们还没设置,直接回车OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root passwordOK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y <---是否设定root密码,当然设置了,输入Y回车 New password: <New password: <---输入root密码,并回车,输入的过程中不会有任何显示 ReRe-enter new password: <---再次输入root密码,并回车,输入的过程中不会有任何显示 Password updated successfullyPassword updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account createdto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into a production environment. Remove anonymous usersgo a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y <---是否删除匿名用户,删除,输入Y回车 ... Success... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y <---是否删禁止root用户远程登录,当然禁止,输入Y回车 ... Success... Success!
By default, MySQL comes with a database named 'test' that anyone can access. This is also intended onlyaccess. This is also intended only for testing, and should be removedbefore moving into a production environment. Remove test database and access to itbefore moving into a production environment.
Remove test database and access to it? [Y/n] <---是否删除测试数据库test,删除,输入Y回车- Dropping test database... ... Success
... Success!
- Removing privileges on test database... ... Success
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y <---刷新权限,输入Y回车 ... Success... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MySQLinstallation should now be secure. Thanksinstallation should now be secure.
Thanks for using MySQL!