Wednesday, September 20, 2017

Debian Stretch: Installing MySql (for fresh installation)

Remove all MariaDB
# apt-get --purge remove mysql-server mysql-client 
or 
# apt-get --purge remove mariadb-server-10.1 mariadb-server-core-10.1 mariadb-client-10.1 
# apt-get autoclean && apt-get autoremove
Note: option purge will remove all mariadb database

Install MySql dependency

# apt-get install lsb-release

Download MySql apt configuration from https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb
# wget --no-check-certificate https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb
Note: File name may change without notice, check latest mysql-apt-config at https://dev.mysql.com/downloads/repo/apt/

Install MySql apt configuration.
# dpkg -i mysql-apt-config_0.8.7-1_all.deb
Choose MySql 5.7 for stable version and continue by click Ok. It will create apt repository file like this:
# cat /etc/apt/sources.list.d/mysql.list
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out entries below, but any other modifications may be lost.
# Use command 'dpkg-reconfigure mysql-apt-config' as root for modifications.
deb http://repo.mysql.com/apt/debian/ stretch mysql-apt-config
deb http://repo.mysql.com/apt/debian/ stretch mysql-5.7
deb http://repo.mysql.com/apt/debian/ stretch mysql-tools
#deb http://repo.mysql.com/apt/debian/ stretch mysql-tools-preview
deb-src http://repo.mysql.com/apt/debian/ stretch mysql-5.7

Run apt update
# apt-get update

Now you are ready to install MySql by issuing command
# apt-get install mysql-server mysql-client
Reading package lists... Done
Building dependency tree     
Reading state information... Done
The following additional packages will be installed:
  libmecab2 mysql-community-client mysql-community-server
The following NEW packages will be installed:
  libmecab2 mysql-client mysql-community-client mysql-community-server
  mysql-server
0 upgraded, 5 newly installed, 0 to remove and 3 not upgraded.
Need to get 36.8 MB of archives.
After this operation, 254 MB of additional disk space will be used.
Do you want to continue? [Y/n]

At the end of installation, you will be ask for MySql root password (Note: this is not root Linux user)
# service mysql status
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; bad; vendor preset: enable
   Active: active (running) since Wed 2017-09-20 08:04:27 WIB; 24s ago
 Main PID: 15189 (mysqld)
   CGroup: /system.slice/mysql.service
           └─15189 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysql

Sep 20 08:04:23 ca01 systemd[1]: Starting MySQL Community Server...
Sep 20 08:04:27 ca01 systemd[1]: Started MySQL Community Server.
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


Reference:
  1. http://mysqlrelease.com/2017/06/debian-9-and-mysql-watch-out/
  2. https://dev.mysql.com/downloads/repo/apt/

No comments:

Post a Comment