idea安装mysql

先检查linux服务器上是否已经安装了mysql

[root@localhost  ~]# rpm -qa | grep mysql

 

未安装则无任何信息返回,若已安装则会返回已安装的版本信息,可通过--nodeps关键字卸载mysql

[root@localhost local]#rpm -e 返回的mysql版本信息 –nodeps

 

2. 下载mysql安装包mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz 

把下载的安装包解压到/usr/local目录里,重命名目录为mysql

[root@localhost ~]# tar -zxf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz -C /usr/local

[root@localhost local]# mv mysql-5.6.33-linux-glibc2.5-x86_64 mysql

 

3. 创建mysql用户组及用户

[root@localhost local]# groupadd mysql

[root@localhost local]# useradd -r -g mysql mysql

 

4. 进入mysql目录,对用户mysql和分组mysql进行授权

[root@localhost mysql]# chown -R mysql:mysql ./

 

5. 进入/mysql/scripts/目录执行mysql_install_db脚本 

[root@localhost mysql]# cd scripts/

[root@localhost scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysql.pid --tmpdir=/tmp

 

安装报错,可直接在线安装perl和autoconf

[root@localhost scripts]# yum install perl

[root@localhost scripts]# yum -y install autoconf

 

再次执行上面的脚本

 

6. 配置my.cnf 

[root@localhost scripts]# vi /etc/my.cnf

datadir = /usr/local/mysql/data

log-error = /usr/local/mysql/data/error.log

pid-file = /usr/local/mysql/data/mysql.pid

user = mysql

tmpdir = /tmp

 

7. 设置启动脚本 

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld

[root@localhost mysql]# chmod 755 /etc/init.d/mysqld

 

8. 启动服务

  service mysqld start

 

9. 进入bin目录连接数据库./mysql 修改root的用户密码和允许远程连接

mysql> use mysql;

mysql> update user set password=passworD("123456") where user='root';

mysql> flush privileges;

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

mysql> flush privileges;

posted @ 2020-10-14 14:15  丁国丰  阅读(685)  评论(0编辑  收藏  举报