mysql安装

1. 下载mysql

2.解压初始化

修改配置文件:

[root@localhost bin]# cat /etc/my.cnf

[mysqld]

#skip-grant-tables

datadir=/usr/local/mysql/data

socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# Settings user and group are ignored when systemd is used.

# If you need to run mysqld under a different user or group,

# customize your systemd unit file for mariadb according to the

# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]

log-error=/var/log/mariadb/mariadb.log

pid-file=/var/run/mariadb/mariadb.pid

#

# include all files from the config directory

#

!includedir /etc/my.cnf.d

---------------------------------------------------------

赋权

chown -R mysql:mysql  data

初始化

mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

添加启动服务

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

[root@localhost mysql]# service mysql start

修改密码(最新版本)

SET PASSWORD FOR 'root'@'localhost' = 'password';

mysql> update mysql.user set authentication_string=password('*******') where user='*******'; #修改密码成功

Query OK, 1row affected,1warning (0.00 sec)

Rows matched: 1Changed:1Warnings:1mysql> flush privileges;  #立即生效

Query OK, 0rows affected (0.00 sec)

mysql> quit

Bye

重启后修改my.cnf中的无密码登录配置

再重启。

mysql -uroot -p


show databases;--若失败,提示reset password

则:

1、修改密码

mysql> set password=password("youpassword");

2、刷新权限

mysql> flush privileges;

你可能感兴趣的:(mysql安装)