统信UOS安装Mysql
解压MySQL8.0.31压缩包
tar -xvf mysql-8.0.31-linux-glibc2.12-x86_64.tar.xz
重命名
mv mysql-8.0.31-linux-glibc2.12-x86_64.tar.xz/ mysql-8.0.31
复制到/usr/local
sudo mv mysql-8.0.31 /usr/local/
创建用户组
sudo groupadd mysql
添加用户
useradd -r -g mysql mysql
创建MySQL数据目录
mkdir -p /data
进入data目录
cd /data/
mkdir -p mysql
修改拥有者
chown mysql:mysql -R /data/mysql
生成编辑配置文件
vim /etc/my.cnf或sudo vim /etc/my.cnf
[mysqld]bind-address=0.0.0.0port=3306user=mysqlbasedir=/usr/local/mysql-8.0.31datadir=/data/mysqlsocket=/tmp/mysql.socklog-error=/data/mysql/mysql.errpid-file=/data/mysql/mysql.pid#character configcharacter_set_server=utf8mb4symbolic-links=0
初始化MYSQL
cd /usr/local/mysql-8.0.31/bin/
./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql-8.0.31/ --datadir=/data/mysql/ --user=mysql --initialize
或
sudo ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql-8.0.31/ --datadir=/data/mysql/ --user=mysql --initialize
查看MySQL初始密码
cat /data/mysql/mysql.err
启动mysql
cp /usr/local/mysql-8.0.31/support-files/mysql.server /etc/init.d/mysql
/etc/init.d/mysql status
启动 service mysql start
查看状态 service mysql status
修改mysql密码
cd /usr/local/mysql-8.0.31/bin/
./mysql -u root -p
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘cyroot’;
修改 vi /etc/my.cnf(注意修改前先停止服务service mysql stop)
default-storage-engine=INNODBperformance_schema=offtable_open_cache=128transaction_isolation=READ-COMMITTEDmax_connections=1000max_connect_errors=6000max_allowed_packet=64Minnodb_file_per_table=1innodb_buffer_pool_size=512Minnodb_flush_method=O_DIRECTinnodb_lock_wait_timeout=1800server-id=1log-bin=mysql-binexpire_logs_days = 2binlog_format=mixedcharacter-set-client-handshake = FALSEcharacter-set-server=utf8mb4collation-server=utf8mb4_general_ciinit_connect='SET default_collation_for_utf8mb4=utf8mb4_general_ci'sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTIONskip-name-resolve[mysql]default-character-set=utf8mb4[mysql.server]default-character-set=utf8mb4
开启MySQL远程权限
#连接数据库
cd /usr/local/mysql-8.0.31/bin/
./mysql -u root -p
#使用mysql数据库
use mysql;
#查询所有用户
select User,Host from user;
±-----------------±----------+
| User | Host |
±-----------------±----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
±-----------------±----------+
#更新root的host %允许所有IP连接
update user set host = ‘%’ where user = ‘root’;
#查看更新结果
select User,Host from user;
±-----------------±----------+
| User | Host |
±-----------------±----------+
| root | % |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
±-----------------±----------+
#刷新权限立即生效
flush privileges;
创建metersphere数据库
CREATE DATABASE metersphere
配置MySQL全局变量
进入mysql安装目录下bin目录
/usr/local/mysql-8.0.31/bin
打开全局变量文件
vim /etc/profile
全局变量文件最后一行增加
export PATH=$PATH:/usr/local/mysql-8.0.31/bin
重新加载变量文件
source /etc/profile
测试----输入mysql -uroot -p密码
来源地址:https://blog.csdn.net/weixin_46448374/article/details/128714274
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341