1. 添加 MySQL 5.6 的 Yum 存储库:
sudo vim /etc/yum.repos.d/mysql56.repo
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=1
gpgcheck=0
2. 安装 MySQL 5.6:
sudo yum install mysql-server
3. 启动 MySQL 服务:
sudo systemctl start mysqld
4. 设置 MySQL 开机启动:
sudo systemctl enable mysqld
5. 安全配置 MySQL:
sudo mysql_secure_installation
此工具将引导你完成一些重要的安全配置步骤,包括设置根密码、删除匿名用户、禁用远程 root 登录等。
6. 验证 MySQL 版本:
mysql -V
创建数据库:
CREATE DATABASE data_demo CHARACTER SET utf8 COLLATE utf8_general_ci;
创建用户:
CREATE USER 'user'@'%' IDENTIFIED BY 'pwd';
赋予用户权限:
GRANT ALL PRIVILEGES ON database.* TO 'domain-admin'@'%';
刷新
FLUSH PRIVILEGES;
5.6版本及以下修改密码命令
SET PASSWORD FOR 'user'@'localhost' = PASSWORD('pwd');
修改表格某个字段名:
ALTER TABLE table
CHANGE recordId recordid VARCHAR(128);
表格新增字段:
ALTER TABLE tb_source_data
ADD line_name VARCHAR(256);
备份数据库:
mysqldump -u user -p database > data_bak.sql
恢复数据库:
mysql -u user -p database < data_bak.sql
备份表格数据:
mysqldump -u your_username -p your_password your_database_name your_table_name > backup.sql
标签:name,5.6,sudo,mysql,MySQL,your,centos7.6 From: https://www.cnblogs.com/sinclair1927/p/17815808.html