欢迎投稿

今日深度:

Mac中MariaDB数据库的安装步骤,macmariadb

Mac中MariaDB数据库的安装步骤,macmariadb


前面看过很多文章,好多文章好像有点步骤好像漏掉了似的,所以自己在前人和自己实践的基础上做了总结希望对读者有帮助。
如标题这个是只针对MAC Mac中有XcodeHomebrew安装工具,这两个工具。
Xcode就不说了,直接是:xcode-select –install
Homebrew的安装方法可以看一下这个连接 https://brew.sh/index_zh-cn
或者直接运行安装Homebrew的命令:
ruby -e “$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)”
这里主要介绍Homebrew

一、Homebrew的检查和更新
1、检查
brew doctor
如检查Homebrew不是最新的版本,可以通过下下面命令来把Homebrew更新到最新
2、更新
brew update
二、在Homebrew仓库中确认MariaDB的版本和安装
1、确认MariaDB的版本
brew info mariadb
2、安装MariaDB
brew install mariadb
3、运行数据库安装程序,分别执行下面的命令来实现安装:
unset TMPDIR
cd /usr/local/Cellar/mariadb/10.3.8/
mysql_install_db
4、运行MariaDB
上面的命令执行结束说明安装好了MariaDB数据库,但是MariaDB数据库服务并没有启动,
启动MariaDB
mysql.server start
5、安全完成安装(一定要执行mysql.server start在完成下面的动作)
通过上面的启动MariaDB数据库服务,你已经可以连接MariaDB的数据库了,
但是还不够安全,通过如下步骤可以完成更全面的设置,
如:重设root用户的密码、移除匿名用户、移除默认的test数据库等等
具体的执行和设置如下:
#10.3.8: mysql_secure_installation
下面会有一些手动的确认:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB 
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current 
password for the root user. If you've just installed MariaDB, and 
you haven't set the root password yet, the password will be blank, 
so you should just press enter here.

Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 
Enter current password for root (enter for none): 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 
Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB 
root user without the proper authorisation.

Set root password? [Y/n] Y 
New password: 
Re-enter new password: 
Password updated successfully! 
Reloading privilege tables.. 
... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone 
to log into MariaDB without having to have a user account created for 
them. This is intended only for testing, and to make the installation 
go a bit smoother. You should remove them before moving into a 
production environment.

Remove anonymous users? [Y/n] Y 
 ... Success!

Normally, root should only be allowed to connect from 'localhost'. This 
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n 
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can 
access. This is also intended only for testing, and should be removed 
before moving into a production environment.

Remove test database and access to it? [Y/n] Y 
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far 
will take effect immediately.

Reload privilege tables now? [Y/n] Y 
 ... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB 
installation should now be secure.

Thanks for using MariaDB! 

6、连接MariaDB数据
mysql -u root -p
输入你设置的用户明密码就登录OK了
7、验证MariaDB版本
MariaDB [(none)]> select @@version;
+—————–+
| @@version |
+—————–+
| 10.3.8-MariaDB |
+—————–+
1 row in set (0.00 sec)
8、MariaDB基础命令
下面是MariaDB的一些基础使用命令:
– 显示数据库列表
show databases;
– 切换到名为mysql的数据库,显示该库中的数据表
use mysql;
show tables;
– 显示数据表table的结构
desc table;
– 建数据库A与删数据库A
create database database_A;
drop database database_A;
– 建表:
use database_A;
create table table_A(字段列表);
drop table table_A;
– 显示表中的记录:
select * from table_A;
– 清空表中记录:
delete from table_A;

www.htsjk.Com true http://www.htsjk.com/mariadb/37130.html NewsArticle Mac中MariaDB数据库的安装步骤,macmariadb 前面看过很多文章,好多文章好像有点步骤好像漏掉了似的,所以自己在前人和自己实践的基础上做了总结希望对读者有帮助。 如标题这个是只针...
相关文章
    暂无相关文章
评论暂时关闭