1、MysqL二进制安装包 mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
2、MysqL源码包安装 mysql-5.6.33.tar.gz
区别:
二进制包安装方便不需要编译,直接解压就可以使用。但是二进制包要比源码包大。下面介绍一下MysqL二进制安装包的安装方法。(写的不好的地方大家多多指教)
1、添加MysqL用户
useradd MysqL -s /sbin/nologin -M
参数说明:-s /sbin/nologin 表示禁止该用户登录,
-M 不用创建家目录。
2、创建一个目录 mkdir /application
解释:二进制MysqL安装包默认安装在/usr/local下,这个目录可以不创建,这个只是个人习惯。运维工作人员的习惯就是走老路,避免新的坑。
3、解压安装包
tar -xvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
4、将解压文件重命名
mv mysql-5.6.33-linux-glibc2.5-x86_64 /application/mysql-5.6.33
5、建立一个软连接
ln -s /application/mysql-5.6.33 /application/MysqL
6、修改MysqL的所属主、所属组
chown -R MysqL.MysqL /application/MysqL/
7、初始化数据库
/application/MysqL/scripts/MysqL_install_db --basedir=/application/MysqL --datadir=/application/MysqL/data/ --user=MysqL
8、拷贝MysqL启动脚本
cp /application/MysqL/support-files/MysqL.server /etc/init.d/MysqLd
9、给启动脚本加执行权限
chmod +x /etc/init.d/MysqLd
10、二进制安装包默认安装路径是/usr/local,所以将脚本中的/usr/local替成/application
11、启动MysqL
/etc/init.d/MysqLd start
Starting MysqL…………………………………. [确定]
如果报以下错误:
Starting MysqL.180223 17:46:06 MysqLd_safe Directory ‘/var/lib/MysqL’ for UNIX socket file don’t exists.
The server quit without updating PID file (/var/lib/MysqL/i[Failed]3fkghffrq11dqZ.pid).
将/etc/my.cnf文件重新命名
12、检查MysqL是否真正启动
netstat -nplt | grep 3306
tcp 0 0 :::3306 :::* LISTEN 15064/MysqLd
13、如果发现MysqL端口没有启动,请看/application/MysqL/data/.err日志,根据报错信息在调试
vim /application/MysqL/data/.err
14、设置MysqL开机自启动
chkconfig --add MysqLd
chkconfig MysqLd on
15、设置全局变量
vim /etc/profile
在文件最后加入
export PATH=/application/MysqL/bin:$PATH
16、登录MysqL,这个时候不需要密码也可以登录,并且是root用户
[root@Jhyeliu data]# MysqL
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 1
Server version: 5.6.33 MysqL Community Server (GPL)
copyright (c) 2000, 2016, 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>
17、如果出现下面这个情况,重新初始化数据。
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
1)、删除初始化的data目录 rm -rf /application/MysqL/data
2)、重新初始化
MysqLadmin -u root password 'password'
19、清理无用的库
drop database test ;
20、清理无用的用户
select user,host from MysqL.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| | jhyeliu |
| root | jhyeliu |
| | localhost |
| root | localhost |
+------+-----------+
drop user "root"@"::1";
Query OK, 0 rows affected (0.05 sec)
drop user ""@"localhost";
Query OK, 0 rows affected (0.00 sec)
drop user ""@"jhyeliu";
Query OK, 0 rows affected (0.00 sec)
drop user "root"@"jhyeliu";
Query OK, 0 rows affected (0.00 sec)
select user,host from MysqL.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
flush privileges;
至此MysqL数据库就算基本完成了。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。