#binary log
log-bin = mysql-bin
binlog_format = mixed
expire_logs_day = 30
#slow query log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 3
log-queries-not-using-indexes
log-slow-admin-statements
现在可以启动mysql了
# /usr/local/mysql/bin/mysqld_safe –user=mysql &
CentOS7 不能使用service控制mysql服务,而源码安装的mysql也没有提供Systemd的控制脚本。
于是编辑/etc/rc.d/rc.local文件,添加mysql的开机启动命令。
/usr/local/mysql/bin/mysqld_safe –user=mysql &
然后给/etc/rc.d/rc.local添加可执行权限
sudo chmod a+x /etc/rc.d/rc.local
9.修改root密码(或可使用mysqladmin设置密码
$/usr/loca/mysql/bin/mysql -u root
use mysql;
UPDATE user SET password = PASSWORD(‘123456′) WHERE user = ‘root';
GRANT ALL PRIVILEGES ON *.* TO root@’%’ IDENTIFIED BY ‘123456′;
FLUSH PRIVILEGES;
使用mysqladmin设置密码:(使用mysqladmin可以进入到bin目录或者设置PATH)
$mysqladmin -u root password 123456
至此,安装基本完成了,一个mysql就能用了。
设置之前,我们需要先设置PATH,要不不能直接调用mysql
修改/etc/profile文件,在文件末尾添加
$vim /etc/profile
PATH=/usr/local/mysql/bin:$PATH
export PATH
关闭文件,运行下面的命令,让配置立即生效
$source /etc/profile
连接本机MySQL
$mysql –u root –p
提示输入password,默认为空,按Enter即
设置选项文件,将配置文件拷贝到/etc下
$cp support-files/my-medium.cnf /etc/mysql.cnf
设置开机自启动
$cp support-files/mysql.server /etc/init.d/mysql
$chmod +x /etc/init.d/mysql
$ chkconfig mysql on
通过服务来启动和关闭Mysql
$service mysql start
$ service mysql stop
mysqladmin -u root password '123456'
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
(责任编辑:好模板) |