Setting up MariaDB Repositories
centos8 mariadb
touch /etc/yum.repos.d/MariaDB.repo &&
echo "# MariaDB 10.4 CentOS repository list - created 2020-04-21 01:44 UTC" >> /etc/yum.repos.d/MariaDB.repo &&
echo "# http://downloads.mariadb.org/mariadb/repositories/" >> /etc/yum.repos.d/MariaDB.repo &&
echo "[mariadb]" >> /etc/yum.repos.d/MariaDB.repo &&
echo "name = MariaDB" >> /etc/yum.repos.d/MariaDB.repo &&
echo "baseurl = http://yum.mariadb.org/10.4/centos8-amd64" >> /etc/yum.repos.d/MariaDB.repo &&
echo "module_hotfixes=1" >> /etc/yum.repos.d/MariaDB.repo &&
echo "gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB" >> /etc/yum.repos.d/MariaDB.repo &&
echo "gpgcheck=1" >> /etc/yum.repos.d/MariaDB.repo
sudo dnf install MariaDB-server -y
sudo systemctl start mariadb
# 自動移動設定
sudo systemctl enable mariadb
centos7 mariadb
古いものがあれば削除
# 存在を確認
rpm -qa | grep -i "mariadb"
# 削除
yum remove mariadb mariadb-server
rm -rf /var/lib/mysql
rm -rf /etc/my.cnf
※ mariadb-libsを削除するとpostfilxも削除されるので必要であればインストールし直す
yum install mariadb mariadb-server
自動起動設定
systemctl enable mariadb.service
起動
systemctl start mariadb.service
centos6 MySQL5.6
既存のMySQLを確認
rpm -qa | grep mysql
MySQLの削除
yum remove mysql*
rpmを追加
yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
yumでMySQL5.6を追加
yum install mysql mysql-devel mysql-server mysql-utilities
確認
rpm -qa | grep mysql
mysql --version
サーバーを起動したら自動的に MySQL Server が起動するように設定
chkconfig mysqld on
文字コードの設定
vi /etc/my.cnf
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
MySQLサーバの起動
service mysqld start
ユーザODBCの作成
[root@localhost]# mysql -u root -p
Enter password:[Enter](※初期設定はパスワードなし)
CREATE USER 'ODBC'@'192.168.11.10' IDENTIFIED BY 'password';
grant all privileges on *.* to 'ODBC'@'192.168.11.10' ;
exit;
ODBCユーザで入れることを確認する
mysql -h 192.168.11.10 -u ODBC -p
Enter password:password
データベースの作成
# 「kokyaku_kanri」データベースの作成
CREATE SCHEMA kokyaku_kanri;
# 「kokyaku_kanri」データベースを使用
USE kokyaku_kanri
# 「t_kokyaku」テーブルの作成
CREATE TABLE t_kokyaku(kid VARCHAR(4) PRIMARY KEY, name VARCHAR(20), todofuken VARCHAR(10), birthday DATE, point INT);
# レコードの追加
INSERT INTO t_kokyaku VALUES('C001', '渡部 剛', '栃木県', '1984-5-16', 1908);
INSERT INTO t_kokyaku VALUES('C002', '小松 直利', '青森県', '1981-8-28', 1722);
インストール後のセキュリティ設定
mysql_secure_installation - MariaDB Knowledge Base
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
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none): #### Enter
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] n #### ソケット認証を有効にするか
... skipping.
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] n #### root パスワードを変更するか
... skipping.
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] Y #### root ユーザのリモートログインを無効にするか
... Success!
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 #### テスト DB を削除するか
- 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!