【实战】maridb10.0.15oncentos6.5安装(二)

2015-02-03 12:04:07 · 作者: · 浏览: 120
** 注:在启动MySQL服务时,会按照一定次序搜索my.cnf, 1)./etc/my.cnf 2)./etc/mysql/my.cnf 3).SYSCONFDIR/my.cnf 4).$MYSQL_HOME/my.cnf 5).defaults-extra-file 6).~/.my.cnf 7).~/.mylogin.cnf **********如果不指定defaults-file可能会如下错误: [Warning] InnoDB: Cannot open table mysql/slave_master_info [Warning] InnoDB: Cannot open table mysql/slave_worker_info [Warning] InnoDB: Cannot open table mysql/slave_relay_log_info ****************/ 提供二进制文件,库文件,头文件,man手册 echo 'export PATH=/data/apps/mysql/bin:$PATH' > /etc/profile.d/mysql.sh echo '/data/apps/mysql/lib' > /etc/ld.so.conf.d/mysql.conf ln -sv /usr/local/include /usr/include/mysql echo 'MANPATH /data/apps/mysql' >> /etc/man.config man -M /data/apps/mysql/man mysqld --让man手册立刻生效为最新 6.启动MySQL 添加服务,拷贝服务脚本到init.d目录,并设置开机启动 cd /usr/local/mysql/ cp support-files/mysql.server /etc/init.d/mysql chkconfig mysql on service mysql start 7.配置mysql用户 MySQL启动成功后,root默认没有密码,我们需要设置root密码。 7.1修改/etc/profile文件,在文件末尾添加 #vi /etc/profile PATH=/usr/local/mysql/bin:$PATH export PATH #source /etc/profile 现在,我们可以在终端内直接输入mysql进入,mysql的环境了 执行下面的命令修改root密码 --7.2修改mysql管理员密码 ---方法1: mysql -uroot -h127.0.0.1 -p SET PASSWORD = PASSWORD('password'); flush privileges; --7.3 登录mysql # mysql -uroot -ppassword --7.4 设置mysql用户安全(不适用) select user,host from mysql.user; delete from mysql.user where (user,host) not in(select 'root','localhost'); #修改root的用户名和密码 update mysql.user set user='system',password=password('password') where user='root'; truncate table mysql.db; #新建管理员的语法 grant all on *.* to 'root'@'%' identified by "password" WITH GRANT OPTION; --7.5 设置root用户可以远程访问 --方法1:授权法 mysql>
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; flush privileges; select host,user,password from mysql.user; --方法2:修改表 mysql> update user set host ='%' where user = 'root'; mysql> flush privileges; ----7.6设置linux脚本 vi ~/.bash_profile #ocpyang set alias mysql="mysql -uroot -ppassword --auto-rehash" alias errorlog="cat /usr/local/mysql/mysql_logs/error_log/error.log" alias mycnf="cd /usr/local/mysql" export PATH=/usr/local/mysql/scripts:$PATH source ~/.bash_profile ----7.7修改权限 chown -R mysql /usr/local/mysql chgrp -R mysql /usr/local/mysql ----常见启动错误或警告 cat /usr/local/mysql/mysql_logs/error_log/error.log Warning] 'proxies_priv' entry '@% root@sphinx.ocp.com' ignored in --skip-name-resolve mode. 解决办法: delete from mysql.proxies_priv where host='sphinx.ocp.com'; commit; flush privileges;