标签:htm err cti amount rpm lis 使用 重置 erro
本人尝试过使用源码安装方式,那叫一个头疼,各种问题,于是采用yum方式安装,没想到如此简单:
此服务器是刚买的,所以以前没有安装过mysql,如果以前安装过mysql的,好像要卸载干净再安装(其实我也不懂~)。
开始吧:
1、配置yum源
# 下载mysql源安装包(默认5.7最新版本) [root@pd ~]# wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm # 安装mysql源 [root@pd ~]# rpm -ivh mysql57-community-release-el7-8.noarch.rpm
检测yum源是否安装成功
[root@pd ~]# yum repolist enabled | grep "mysql.*-community.*"
如上图所示即安装成功
2、安装MySQL
[root@pd ~]# yum -y install mysql-server
等一会就安装好了
默认配置文件路径:
/etc/my.cnf # 配置文件 /var/log/var/log/mysqld.log # 日志文件 /usr/lib/systemd/system/mysqld.service # 服务启动脚本 /var/run/mysqld/mysqld.pid # socket文件
3、配置 my.cnf
[root@pd ~]# vim /etc/my.cnf
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock server_id = 1 expire_logs_days = 3 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
4、启动mysql服务
[root@pd ~]# service mysqld restart
5、查看密码(因为安装好后,第一次登录密码为随机密码)
[root@pd ~]# grep "password" /var/log/mysqld.log
输入 mysql -u root -p 回车,再输入上面的随机密码,回车,即可登录MySQL。
6、重置密码
注意:
mysql> alter user "root"@"localhost" identified by "新密码";
记得要刷新权限
mysql> flush privileges;
输入 exit 退出 MySQL,再次登录就可以用设置好的密码了。
7、添加远程登录用户
默认只允许 root 帐户在本地登录,如果要在其它机器上连接MySQL,必须修改 root 允许远程连接,或者添加一个允许远程连接的帐户,为了安全起见,可以添加一个新的帐户。
1
标签:htm err cti amount rpm lis 使用 重置 erro
原文地址:https://www.cnblogs.com/believepd/p/10458000.html