linux 利用yum源安装mysql

来源:互联网 发布:编辑声音的软件 编辑:程序博客网 时间:2024/06/05 15:17

环境

1, CentOS 7
2, MySQL 5.6

步骤

1,添加mysql源

 rpm -ivh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

2,安装mysql

yum install mysql-server

3,启动mysql

systemctl start mysql

4,查看mysql是否启动

netstat -tlnp | grep mysqlps -ef | grep mysql

5,初次设置root账户密码

mysqladmin -u root password root

6,进入mysql

mysql -uroot -prootshow databases;use mysql;show tables;quit;

7,设置mysql数据编码格式为utf8。

设置:vi /etc/my.cnf-----------------------------[mysqld]character-set-client-handshake=FALSEcharacter_set_server=utf8collation-server=utf8_general_ci[client]default-character-set = utf8[mysql]default-character-set = utf8查看设置结果:mysql> SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';+--------------------------+-----------------+| Variable_name            | Value           |+--------------------------+-----------------+| character_set_client     | utf8            || character_set_connection | utf8            || character_set_database   | utf8            || character_set_filesystem | binary          || character_set_results    | utf8            || character_set_server     | utf8            || character_set_system     | utf8            || collation_connection     | utf8_general_ci || collation_database       | utf8_general_ci || collation_server         | utf8_general_ci |+--------------------------+-----------------+10 rows in set (0.01 sec)

其它

启动mysql:systemctl start mysql / systemctl start mysqld
停止mysql:systemctl stop mysql / systemctl stop mysqld
重启mysql:systemctl restart mysql / systemctl restart mysqld
查看mysql状态:systemctl status mysql / systemctl status mysqld

mysql服务开启:systemctl enable mysqld
mysql服务关闭:systemctl disable mysqld
查看mysql服务是否开启:systemctl list-unit-files|grep mysqld

查看mysql版本:mysql -V
my.cnf配置文件查找顺序:mysqld –help –verbose 2> /dev/null | grep -A1 ‘Default options’

原创粉丝点击