Yum installs MySQL and related directory paths and modifies directories

Source: Internet
Author: User

Sometimes, for convenience, some students like to install MySQL through Yum, without setting up a unified file directory and software catalog, then it will bring a lot of trouble for the subsequent maintenance work! Here's a quick introduction to the Yum installation of MySQL and the associated directory path under this type of installation, and finally a quick introduction to how to change the file directory! Yum installs MySQL1, installs client and server side
#确认mysql是否已安装:    yum list installed mysql*rpm -qa | grep mysql*#查看是否有安装包:yum list mysql*#安装mysql客户端:yum install mysql#安装mysql 服务器端:yum install mysql-serveryum install mysql-devel
2. Start and stop settings
#数据库字符集设置#mysql配置文件/etc/my.cnf中加入default-character-set=utf8#启动mysql服务:service mysqld start#或者/etc/init.d/mysqld start#设置开机启动:chkconfig --add mysqld#查看开机启动设置是否成功chkconfig --list | grep mysql*mysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭#停止mysql服务:service mysqld stop
3, login and forget to change the password
#创建root管理员:#mysqladmin -u root password 666666#登录:mysql -u root -p#如果忘记密码,则执行以下代码来修改密码service mysqld stopmysqld_safe --user=root --skip-grant-tablesmysql -u rootuse mysqlupdate user set password=password("666666") where user="root";flush privileges;
4. Remote Access settings
#开放防火墙的端口号#mysql增加权限:#mysql库中的user表新增一条记录host为“%”,user为“root”。use mysql;UPDATE user SET Host = '%' WHERE User = 'root' LIMIT 1;#%表示允许所有的ip访问
5. Several important directories of MySQL
#(a)数据库目录/var/lib/mysql/#(b)配置文件/usr/share /mysql(mysql.server命令及配置文件)#(c)相关命令/usr/bin(mysqladmin mysqldump等命令)#(d)启动脚本/etc/rc.d/init.d/(启动脚本文件mysql的目录)
CENTOS6 Modify the yum installed MySQL default directory 1. Create a new directory
#数据目录设置为 /home/datamkdir -p /home/data
2. Stop the MySQL service process:
mysqladmin -u root -p shutdown

  

3. Move/var/lib/mysql Entire directory to/home/data

  mv /var/lib/mysql /home/data/
  

4. Modify the configuration file my.cnf
#假如/etc/目录下没有my.cnf配置文档,请到/usr/share/mysql/下找到*.cnf文档#拷贝其中一个到/etc/并改名为my.cnf)中。命令如下:cp /usr/share/mysql/my.cnf /etc/my.cnfvi  my.cnf   [mysqld]port   = 3306socket  = /home/data/mysql/mysql.sock   #修改socket参数
5. Modify the MySQL startup script/etc/init.d/mysql
vi /etc/init.d/mysqldatadir=/home/data/mysql   #修改datadir数据目录的位置#做一个mysql.sock 链接:ln -s /home/data/mysql/mysql.sock /var/lib/mysql/mysql.sock
6. Check the owner and permission of the relevant directory.
7. Restart the MySQL service
/etc/init.d/mysql start

Yum installs MySQL and related directory paths and modifies directories

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.