时间:2021-07-01 10:21:17 帮助过:21人阅读
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------------+
| Database |
+--------------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------------+
4 rows in set (0.00 sec)
设置密码
MariaDB [(none)]> set password for ‘root‘@‘localhost‘ =password(‘redhat‘); MariaDB [(none)]> |
安装mariadb后显示的也是 MariaDB [(none)]> ,可能看起来有点不习惯。下面是第二种方法。
[root@mysql ~]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm [root@mysql ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
[root@mysql ~]# ll /etc/yum.repos.d/ |
[root@mysql ~]# yum install mysql-community-server
安装成功后重启mysql服务。
[root@mysql ~]# service mysqld restart
初次安装mysql,root账户没有密码。
[root@mysql ~]# mysql -u root Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show databases; mysql> |
设置密码
mysql> set password for ‘root‘@‘localhost‘ =password(‘redhat‘); mysql> |
不需要重启数据库即可生效。
在mysql安装过程中如下内容:
所以安装完以后mariadb自动就被替换了,将不再生效。
[root@mysql ~]# rpm -qa |grep mariadb |
三、配置mysql |
mysql配置文件为/etc/my.cnf
最后加上编码配置
[root@mysql ~]# vim /etc/my.cnf
[mysqld] symbolic-links=0 [mysqld_safe] [mysql] !includedir /etc/my.cnf.d |
这里的字符编码必须和/usr/share/mysql/charsets/Index.xml中一致。
[root@mysql ~]# vim /usr/share/mysql/charsets/Index.xml
把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。
[root@mysql ~]# mysql -uroot -p Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. MariaDB [(none)]> grant all privileges on *.* to root@‘%‘identified by ‘redhat‘; MariaDB [(none)]> |
如果是新用户而不是root,则要先新建用户
MariaDB [(none)]> create user ‘admin‘@‘%‘ identified by ‘Xuanbao123456‘; |
此时就可以进行远程连接了。
[root@c1 ~]# mysql -uadmin -p -h192.168.122.20 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. MariaDB [(none)]> |
centos7 mysql数据库安装和配置
标签:令行 启动 redhat reserve data log-error ide red char