Recently in the study of R language, see R and database interaction this part, the hands-on practice a bit, the database chose MySQL, the main record under Linux how to install MySQL.
A lot of information on the Internet has related articles, this is just a record of their own installation process encountered problems and solutions:
Linux kernel version:
uname-a Linux naci 3.19.0-16-generic #16-ubuntu SMP Thu Apr 16:09:58 UTC x86_64 x86_64 x86_64 gnu/linux
1. First install the MySQL database under Liunx
~$sudo apt-get install mysql-server #安装Mysql服务器端~$ps-aux|grep MySQL #检查Mysql服务器进程Beili 10301 0.0 0.0 37080 3604 PTS/7 s+ May 0:00 mysql-u root-pmysql 25125 0.0 0.0 4472 1704? Ss 09:51 0:00/bin/sh/usr/bin/mysqld_safemysql 25496 0.0 3.1 859956 127084? Sl 09:51 0:01/usr/sbin/mysqd--basedir=/usr--datadir=/var/lib/mysql--plugin-dir=/usr/lib/mysql/plugin--log-error= /var/log/mysql/error.log--pid-file=/var/run/mysqld/mysqld.pid--socket=/var/run/mysqld/mysqld.sock--port= 3306beili 26652 0.0 0.0 13708 2180 pts/19 s+ 10:32 0:00 grep--color=auto mysql~$Netstat-nlt|grep 3306 #检查Mysql服务器占用端口TCP 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN ~$/etc/init.d/mysql Status # check MySQL server status with start commandLoaded:loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:enabled) active:active (running) since 4,201 5-05-21 09:51:13 CST; 43min ago process:25126 Execstartpost=/usr/share/mysql/mysql-systemd-start Post (code=exited, status=0/success) process:25122 Execstartpre=/usr/share/mysql/mysql-systemd-start Pre (code=exited, status=0/success) ~$service MySQL status # check MySQL server status through system serviceMysql.service-mysql Community Server loaded:loaded (/lib/systemd/system/mysql.service; enabled; vendor Preset:enab LED) Active:active (running) since four 2015-05-21 09:51:13 CST; 44min ago process:25126 Execstartpost=/usr/share/mysql/mysql-systemd-start Post (code=exited, status=0/success) process:25122 Execstartpre=/usr/share/mysql/mysql-systemd-start Pre (code=exited, status=0/success)
~$whereis mysql # view MySQL files for each file installed directory
MySQL:/usr/bin/mysql/usr/lib/mysql/etc/mysql/usr/include/mysql/usr/share/mysql/usr/share/man/man1/mysql.1.gz
2. Accessing and configuring MySQL
Mysql-u root-p
The default character set for MySQL is latin1, so change to UTF8. Many online articles perform "sudo vi/etc/mysql/my.cnf", but open a look that has two jargon inside:
!includedir/etc/mysql/conf.d/!includedir/etc/mysql/mysql.conf.d/
To think that the MySQL configuration file should be under those two folders, and then try to open the/etc/mysql/mysql.conf.d/under the Mysqld.cnf file, execute the following command:
sudo vi/etc/mysql/mysql.conf.d/mysqld.cnf... [Client]default-character-set=utf8 [Mysqld_safe]socket =/var/run/mysqld/mysqld.socknice = 0[mysqld]character-set-server= Utf8collation-server=utf8_general_ci
...
Note: The brown portion is the added content
Restart the MySQL service and view the settings for the character set:
sudo/etc/init.d/mysql Restart mysql-u root-p Show variables like "%char%"+--------------------------+----------------------------+| Variable_name | Value |+--------------------------+----------------------------+| character_set_client | UTF8 | | character_set_connection | UTF8 | | character_set_database | UTF8 | | character_set_filesystem | binary | | character_set_ Results | UTF8 | | character_set_server | UTF8 | | character_set_system | UTF8 | | Character_sets_dir |/usr/share/mysql/charsets/|+--------------------------+----------------------------+
MySQL installation and configuration under Linux