二 主要 Linux 发行版本安装MariaDB 本文主要介绍两大主要Linux 发行版本类别:
- 使用rpm 软件包格式的RHEL/CentOS/Fedora
- 使用deb软件包格式的Debian /Ubuntu 。
1、使用rpm 软件包格式的RHEL/CentOS/Fedora (1)这里以Fedora 19为例 其中使用Fedora 19 是最简单的,因为这个最新Linux 发行版本可以直接使用yum 软件包工具安装 a、安装软件包 - #yum -y install mariadb-server mariadb
- #systemctl start mysqld.service
- #systemctl enable mysqld.service
- ln -s '/lib/systemd/system/mysqld.service' '/etc/systemd/system
- /multi-user.target.wants/mysqld.service'
2、数据库的基本操作 首次连接MariaDB如图4: - #mysql -u root

图4首次连接MariaDB 可以看到mariadb 版本号是5.5.31-MariaDB MariaDB Server,其他基本操作(和Mysql操作相同)。 查看用户信息 使用内部命令:select user,host,password from mysql.user; 如图5: 
图5查看用户信息 设置root用户密码 - MariaDB [(none)]> set password for root@localhost=password('password');
- Query OK, 0 rows affected (0.00 sec)
- # set root password
- MariaDB [(none)]> set password for root@'127.0.0.1'=password('password');
- Query OK, 0 rows affected (0.00 sec)
删除一些数据库用户(ipv6 和 匿名用户) - MariaDB [(none)]> delete from mysql.user where user='root' and host='::1';
- Query OK, 1 rows affected (0.00 sec)
- MariaDB [(none)]> delete from mysql.user where user='';
- Query OK, 2 rows affected (0.00 sec)
退出后使用root密码重新登录
- #mysql -u root -p
- Enter password:
- # MariaDB root password you set
- Welcome to the MariaDB monitor. Commands end with ; or \g.
- Your MariaDB connection id is 3
- Server version: 5.5.31-MariaDB MariaDB Server
- Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- MariaDB [(none)]>
|