Saturday, January 10, 2015

MySQL Installation on Ubuntu 14.04

Server Installation


To install MySQL, run the following command from a terminal prompt:
 sudo apt-get update  
 sudo apt-get install mysql-server  

The first command is optional, but is a good practice.

During the installation process, you'll be prompted for a password for the admin account:


Do not type 'admin' as your password.

Operational Output

Operational output from a successful install looks something like this:
 craig@U14BASE01:~$ sudo apt-get install mysql-server  
 Reading package lists... Done  
 Building dependency tree      
 Reading state information... Done  
 The following extra packages will be installed:  
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18  
  libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common  
  mysql-server-5.5 mysql-server-core-5.5  
 Suggested packages:  
  libmldbm-perl libnet-daemon-perl libplrpc-perl libsql-statement-perl  
  libipc-sharedcache-perl tinyca mailx  
 The following NEW packages will be installed:  
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18  
  libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common  
  mysql-server mysql-server-5.5 mysql-server-core-5.5  
 0 upgraded, 11 newly installed, 0 to remove and 252 not upgraded.  
 Need to get 9,057 kB of archives.  
 After this operation, 96.5 MB of additional disk space will be used.  
 Do you want to continue? [Y/n] y  
 Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-common all 5.5.40-0ubuntu0.14.04.1 [14.1 kB]  
 Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main libmysqlclient18 amd64 5.5.40-0ubuntu0.14.04.1 [598 kB]  
 Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty/main libdbi-perl amd64 1.630-1 [879 kB]  
 Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty/main libdbd-mysql-perl amd64 4.025-1 [99.3 kB]  
 Get:5 http://us.archive.ubuntu.com/ubuntu/ trusty/main libterm-readkey-perl amd64 2.31-1 [27.4 kB]  
 Get:6 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-client-core-5.5 amd64 5.5.40-0ubuntu0.14.04.1 [703 kB]  
 Get:7 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-client-5.5 amd64 5.5.40-0ubuntu0.14.04.1 [1,466 kB]  
 Get:8 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-core-5.5 amd64 5.5.40-0ubuntu0.14.04.1 [3,215 kB]  
 Get:9 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server-5.5 amd64 5.5.40-0ubuntu0.14.04.1 [1,978 kB]  
 Get:10 http://us.archive.ubuntu.com/ubuntu/ trusty/main libhtml-template-perl all 2.95-1 [65.5 kB]  
 Get:11 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server all 5.5.40-0ubuntu0.14.04.1 [12.4 kB]  
 Fetched 9,057 kB in 6s (1,406 kB/s)                        
 Preconfiguring packages ...  
 Selecting previously unselected package mysql-common.  
 (Reading database ... 168329 files and directories currently installed.)  
 Preparing to unpack .../mysql-common_5.5.40-0ubuntu0.14.04.1_all.deb ...  
 Unpacking mysql-common (5.5.40-0ubuntu0.14.04.1) ...  
 Selecting previously unselected package libmysqlclient18:amd64.  
 Preparing to unpack .../libmysqlclient18_5.5.40-0ubuntu0.14.04.1_amd64.deb ...  
 Unpacking libmysqlclient18:amd64 (5.5.40-0ubuntu0.14.04.1) ...  
 Selecting previously unselected package libdbi-perl.  
 Preparing to unpack .../libdbi-perl_1.630-1_amd64.deb ...  
 Unpacking libdbi-perl (1.630-1) ...  
 Selecting previously unselected package libdbd-mysql-perl.  
 Preparing to unpack .../libdbd-mysql-perl_4.025-1_amd64.deb ...  
 Unpacking libdbd-mysql-perl (4.025-1) ...  
 Selecting previously unselected package libterm-readkey-perl.  
 Preparing to unpack .../libterm-readkey-perl_2.31-1_amd64.deb ...  
 Unpacking libterm-readkey-perl (2.31-1) ...  
 Selecting previously unselected package mysql-client-core-5.5.  
 Preparing to unpack .../mysql-client-core-5.5_5.5.40-0ubuntu0.14.04.1_amd64.deb ...  
 Unpacking mysql-client-core-5.5 (5.5.40-0ubuntu0.14.04.1) ...  
 Selecting previously unselected package mysql-client-5.5.  
 Preparing to unpack .../mysql-client-5.5_5.5.40-0ubuntu0.14.04.1_amd64.deb ...  
 Unpacking mysql-client-5.5 (5.5.40-0ubuntu0.14.04.1) ...  
 Selecting previously unselected package mysql-server-core-5.5.  
 Preparing to unpack .../mysql-server-core-5.5_5.5.40-0ubuntu0.14.04.1_amd64.deb ...  
 Unpacking mysql-server-core-5.5 (5.5.40-0ubuntu0.14.04.1) ...  
 Processing triggers for man-db (2.6.7.1-1) ...  
 Setting up mysql-common (5.5.40-0ubuntu0.14.04.1) ...  
 Selecting previously unselected package mysql-server-5.5.  
 (Reading database ... 168685 files and directories currently installed.)  
 Preparing to unpack .../mysql-server-5.5_5.5.40-0ubuntu0.14.04.1_amd64.deb ...  
 Unpacking mysql-server-5.5 (5.5.40-0ubuntu0.14.04.1) ...  
 Selecting previously unselected package libhtml-template-perl.  
 Preparing to unpack .../libhtml-template-perl_2.95-1_all.deb ...  
 Unpacking libhtml-template-perl (2.95-1) ...  
 Selecting previously unselected package mysql-server.  
 Preparing to unpack .../mysql-server_5.5.40-0ubuntu0.14.04.1_all.deb ...  
 Unpacking mysql-server (5.5.40-0ubuntu0.14.04.1) ...  
 Processing triggers for ureadahead (0.100.0-16) ...  
 ureadahead will be reprofiled on next reboot  
 Processing triggers for man-db (2.6.7.1-1) ...  
 Setting up libmysqlclient18:amd64 (5.5.40-0ubuntu0.14.04.1) ...  
 Setting up libdbi-perl (1.630-1) ...  
 Setting up libdbd-mysql-perl (4.025-1) ...  
 Setting up libterm-readkey-perl (2.31-1) ...  
 Setting up mysql-client-core-5.5 (5.5.40-0ubuntu0.14.04.1) ...  
 Setting up mysql-client-5.5 (5.5.40-0ubuntu0.14.04.1) ...  
 Setting up mysql-server-core-5.5 (5.5.40-0ubuntu0.14.04.1) ...  
 Setting up mysql-server-5.5 (5.5.40-0ubuntu0.14.04.1) ...  
 141222 12:43:00 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.  
 mysql start/running, process 6769  
 Setting up libhtml-template-perl (2.95-1) ...  
 Processing triggers for ureadahead (0.100.0-16) ...  
 Setting up mysql-server (5.5.40-0ubuntu0.14.04.1) ...  
 Processing triggers for libc-bin (2.19-0ubuntu6) ...  
 craig@U14BASE01:~$   

Verification

The MySQL server should be started automatically once the installation is completed. To verify the installation, we'll want to see if the service is running.

Type this from the terminal:
 sudo netstat -tap | grep mysql  

I get this output:
 craig@U14MYSQL01:~$ netstat -tap | grep mysql  
 (Not all processes could be identified, non-owned process info  
  will not be shown, you would have to be root to see it all.)  
 tcp    0   0 localhost:mysql     *:*           LISTEN   -          



Workbench Installation


There are two ways to go about this.

I prefer to use the terminal session and type:
 sudo apt-get install mysql-workbench  

Operational Output

This approach worked successfully for me:
 craig@U14BASE01:~$ sudo apt-get install mysql-workbench  
 Reading package lists... Done  
 Building dependency tree      
 Reading state information... Done  
 The following extra packages will be installed:  
  libctemplate2 libgtkmm-2.4-1c2a liblua5.1-0 libmysqlcppconn7 libodbc1  
  libpcrecpp0 libtinyxml2.6.2 libvsqlitepp3 libzip2 mysql-utilities  
  mysql-workbench-data python-mysql.connector python-paramiko python-pyodbc  
  python-pysqlite2 ttf-bitstream-vera  
 Suggested packages:  
  libmyodbc odbc-postgresql tdsodbc unixodbc-bin python-pysqlite2-doc  
  python-pysqlite2-dbg  
 The following NEW packages will be installed:  
  libctemplate2 libgtkmm-2.4-1c2a liblua5.1-0 libmysqlcppconn7 libodbc1  
  libpcrecpp0 libtinyxml2.6.2 libvsqlitepp3 libzip2 mysql-utilities  
  mysql-workbench mysql-workbench-data python-mysql.connector python-paramiko  
  python-pyodbc python-pysqlite2 ttf-bitstream-vera  
 0 upgraded, 17 newly installed, 0 to remove and 252 not upgraded.  
 Need to get 11.0 MB of archives.  
 After this operation, 87.6 MB of additional disk space will be used.  
 Do you want to continue? [Y/n] y  
 Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libgtkmm-2.4-1c2a amd64 1:2.24.4-1ubuntu1 [655 kB]  
 Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main liblua5.1-0 amd64 5.1.5-5ubuntu0.1 [99.9 kB]  
 Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty/main libodbc1 amd64 2.2.14p2-5ubuntu5 [175 kB]  
 Get:4 http://us.archive.ubuntu.com/ubuntu/ trusty/main libpcrecpp0 amd64 1:8.31-2ubuntu2 [14.5 kB]  
 Get:5 http://us.archive.ubuntu.com/ubuntu/ trusty/universe libtinyxml2.6.2 amd64 2.6.2-2 [35.0 kB]  
 Get:6 http://us.archive.ubuntu.com/ubuntu/ trusty/universe libvsqlitepp3 amd64 0.3.12-1ubuntu1 [44.2 kB]  
 Get:7 http://us.archive.ubuntu.com/ubuntu/ trusty/universe libctemplate2 amd64 2.2-4ubuntu3 [136 kB]  
 Get:8 http://us.archive.ubuntu.com/ubuntu/ trusty/main libmysqlcppconn7 amd64 1.1.3-5 [292 kB]  
 Get:9 http://us.archive.ubuntu.com/ubuntu/ trusty/main libzip2 amd64 0.10.1-1.2 [29.0 kB]  
 Get:10 http://us.archive.ubuntu.com/ubuntu/ trusty/universe python-mysql.connector all 1.1.6-1 [67.2 kB]  
 Get:11 http://us.archive.ubuntu.com/ubuntu/ trusty/universe mysql-utilities all 1.3.5-2 [306 kB]  
 Get:12 http://us.archive.ubuntu.com/ubuntu/ trusty/universe mysql-workbench-data all 6.0.8+dfsg-2 [1,149 kB]  
 Get:13 http://us.archive.ubuntu.com/ubuntu/ trusty/main python-paramiko all 1.10.1-1git1build1 [106 kB]  
 Get:14 http://us.archive.ubuntu.com/ubuntu/ trusty/universe python-pyodbc amd64 3.0.6-2 [51.4 kB]  
 Get:15 http://us.archive.ubuntu.com/ubuntu/ trusty/universe python-pysqlite2 amd64 2.6.3-3 [36.4 kB]  
 Get:16 http://us.archive.ubuntu.com/ubuntu/ trusty/universe mysql-workbench amd64 6.0.8+dfsg-2 [7,449 kB]  
 Get:17 http://us.archive.ubuntu.com/ubuntu/ trusty/universe ttf-bitstream-vera all 1.10-8 [352 kB]  
 Fetched 11.0 MB in 4s (2,655 kB/s)        
 Selecting previously unselected package libgtkmm-2.4-1c2a:amd64.  
 (Reading database ... 168785 files and directories currently installed.)  
 Preparing to unpack .../libgtkmm-2.4-1c2a_1%3a2.24.4-1ubuntu1_amd64.deb ...  
 Unpacking libgtkmm-2.4-1c2a:amd64 (1:2.24.4-1ubuntu1) ...  
 Selecting previously unselected package liblua5.1-0:amd64.  
 Preparing to unpack .../liblua5.1-0_5.1.5-5ubuntu0.1_amd64.deb ...  
 Unpacking liblua5.1-0:amd64 (5.1.5-5ubuntu0.1) ...  
 Selecting previously unselected package libodbc1:amd64.  
 Preparing to unpack .../libodbc1_2.2.14p2-5ubuntu5_amd64.deb ...  
 Unpacking libodbc1:amd64 (2.2.14p2-5ubuntu5) ...  
 Selecting previously unselected package libpcrecpp0:amd64.  
 Preparing to unpack .../libpcrecpp0_1%3a8.31-2ubuntu2_amd64.deb ...  
 Unpacking libpcrecpp0:amd64 (1:8.31-2ubuntu2) ...  
 Selecting previously unselected package libtinyxml2.6.2:amd64.  
 Preparing to unpack .../libtinyxml2.6.2_2.6.2-2_amd64.deb ...  
 Unpacking libtinyxml2.6.2:amd64 (2.6.2-2) ...  
 Selecting previously unselected package libvsqlitepp3:amd64.  
 Preparing to unpack .../libvsqlitepp3_0.3.12-1ubuntu1_amd64.deb ...  
 Unpacking libvsqlitepp3:amd64 (0.3.12-1ubuntu1) ...  
 Selecting previously unselected package libctemplate2.  
 Preparing to unpack .../libctemplate2_2.2-4ubuntu3_amd64.deb ...  
 Unpacking libctemplate2 (2.2-4ubuntu3) ...  
 Selecting previously unselected package libmysqlcppconn7.  
 Preparing to unpack .../libmysqlcppconn7_1.1.3-5_amd64.deb ...  
 Unpacking libmysqlcppconn7 (1.1.3-5) ...  
 Selecting previously unselected package libzip2.  
 Preparing to unpack .../libzip2_0.10.1-1.2_amd64.deb ...  
 Unpacking libzip2 (0.10.1-1.2) ...  
 Selecting previously unselected package python-mysql.connector.  
 Preparing to unpack .../python-mysql.connector_1.1.6-1_all.deb ...  
 Unpacking python-mysql.connector (1.1.6-1) ...  
 Selecting previously unselected package mysql-utilities.  
 Preparing to unpack .../mysql-utilities_1.3.5-2_all.deb ...  
 Unpacking mysql-utilities (1.3.5-2) ...  
 Selecting previously unselected package mysql-workbench-data.  
 Preparing to unpack .../mysql-workbench-data_6.0.8+dfsg-2_all.deb ...  
 Unpacking mysql-workbench-data (6.0.8+dfsg-2) ...  
 Selecting previously unselected package python-paramiko.  
 Preparing to unpack .../python-paramiko_1.10.1-1git1build1_all.deb ...  
 Unpacking python-paramiko (1.10.1-1git1build1) ...  
 Selecting previously unselected package python-pyodbc.  
 Preparing to unpack .../python-pyodbc_3.0.6-2_amd64.deb ...  
 Unpacking python-pyodbc (3.0.6-2) ...  
 Selecting previously unselected package python-pysqlite2.  
 Preparing to unpack .../python-pysqlite2_2.6.3-3_amd64.deb ...  
 Unpacking python-pysqlite2 (2.6.3-3) ...  
 Selecting previously unselected package mysql-workbench.  
 Preparing to unpack .../mysql-workbench_6.0.8+dfsg-2_amd64.deb ...  
 Unpacking mysql-workbench (6.0.8+dfsg-2) ...  
 Selecting previously unselected package ttf-bitstream-vera.  
 Preparing to unpack .../ttf-bitstream-vera_1.10-8_all.deb ...  
 Unpacking ttf-bitstream-vera (1.10-8) ...  
 Processing triggers for man-db (2.6.7.1-1) ...  
 Processing triggers for hicolor-icon-theme (0.13-1) ...  
 Processing triggers for mime-support (3.54ubuntu1) ...  
 Processing triggers for gnome-menus (3.10.1-0ubuntu2) ...  
 Processing triggers for desktop-file-utils (0.22-1ubuntu1) ...  
 Processing triggers for bamfdaemon (0.5.1+14.04.20140409-0ubuntu1) ...  
 Rebuilding /usr/share/applications/bamf-2.index...  
 Processing triggers for shared-mime-info (1.2-0ubuntu3) ...  
 Processing triggers for fontconfig (2.11.0-0ubuntu4.1) ...  
 Setting up libgtkmm-2.4-1c2a:amd64 (1:2.24.4-1ubuntu1) ...  
 Setting up liblua5.1-0:amd64 (5.1.5-5ubuntu0.1) ...  
 Setting up libodbc1:amd64 (2.2.14p2-5ubuntu5) ...  
 Setting up libpcrecpp0:amd64 (1:8.31-2ubuntu2) ...  
 Setting up libtinyxml2.6.2:amd64 (2.6.2-2) ...  
 Setting up libvsqlitepp3:amd64 (0.3.12-1ubuntu1) ...  
 Setting up libctemplate2 (2.2-4ubuntu3) ...  
 Setting up libmysqlcppconn7 (1.1.3-5) ...  
 Setting up libzip2 (0.10.1-1.2) ...  
 Setting up python-mysql.connector (1.1.6-1) ...  
 Setting up mysql-utilities (1.3.5-2) ...  
 Setting up mysql-workbench-data (6.0.8+dfsg-2) ...  
 Setting up python-paramiko (1.10.1-1git1build1) ...  
 Setting up python-pyodbc (3.0.6-2) ...  
 Setting up python-pysqlite2 (2.6.3-3) ...  
 Setting up mysql-workbench (6.0.8+dfsg-2) ...  
 Setting up ttf-bitstream-vera (1.10-8) ...  
 Processing triggers for libc-bin (2.19-0ubuntu6) ...  



Workbench Installation (alternate approach)


You can also download the Workbench from this link at dev.mysql.com
and select:



Once the file has downloaded, navigate to the directory containing the file and type:
 sudo dpkg -i mysql-workbench-community-6.2.4-1ubu1404-amd64.deb  

Operational Output

I had some errors when I tried to install this way:
 craig@U14MYSQL01:~/Downloads$ sudo dpkg -i mysql-workbench-community-6.2.4-1ubu1404-amd64.deb   
 Selecting previously unselected package mysql-workbench-community.  
 (Reading database ... 169589 files and directories currently installed.)  
 Preparing to unpack mysql-workbench-community-6.2.4-1ubu1404-amd64.deb ...  
 Unpacking mysql-workbench-community (6.2.4-1ubu1404) ...  
 dpkg: dependency problems prevent configuration of mysql-workbench-community:  
  mysql-workbench-community depends on libctemplate2; however:  
  Package libctemplate2 is not installed.  
  mysql-workbench-community depends on libgtkmm-2.4-1c2a (>= 1:2.24.0); however:  
  Package libgtkmm-2.4-1c2a is not installed.  
  mysql-workbench-community depends on libpcrecpp0 (>= 7.7); however:  
  Package libpcrecpp0 is not installed.  
  mysql-workbench-community depends on libtinyxml2.6.2; however:  
  Package libtinyxml2.6.2 is not installed.  
  mysql-workbench-community depends on libzip2 (>= 0.10); however:  
  Package libzip2 is not installed.  
  mysql-workbench-community depends on python-paramiko; however:  
  Package python-paramiko is not installed.  
 dpkg: error processing package mysql-workbench-community (--install):  
  dependency problems - leaving unconfigured  
 Processing triggers for gnome-menus (3.10.1-0ubuntu2) ...  
 Processing triggers for desktop-file-utils (0.22-1ubuntu1) ...  
 Processing triggers for bamfdaemon (0.5.1+14.04.20140409-0ubuntu1) ...  
 Rebuilding /usr/share/applications/bamf-2.index...  
 Processing triggers for mime-support (3.54ubuntu1) ...  
 Processing triggers for shared-mime-info (1.2-0ubuntu3) ...  
 Processing triggers for hicolor-icon-theme (0.13-1) ...  
 Errors were encountered while processing:  
  mysql-workbench-community  

See this article on Creating a connection using MySQL Workbench.


Remote Access


If you'll be connecting to MySQL from a remote machine, you'll want to enable remote access.

Run this command:
 sudo gedit /etc/mysql/my.cnf  

and edit out this line:
 # Instead of skip-networking the default is now to listen only on  
 # localhost which is more compatible and is not less secure.  
 # bind-address          = 127.0.0.1  

From a remote machine, type:
  mysql -h <host> -u <user> -p <database>

Note that you don't input your password in this command string.  The "-p" flag will prompt you for it at the terminal.


References

  1. [Ubuntu Community Wiki] Installing MySQL on Ubuntu 12.04
  2. Helpful Commands:
    1. Restarting MySQL Server
      1. sudo service mysql restart
    2. Installing MySQL Workbench
      1. sudo apt-get install mysql-workbench
    3. What Port is MySQL Server running on?
      1. grep port /etc/mysql/my.cnf 
  3. Remote Connectivity
    1. [Rackspace] Connect to your database remotely
      1. This tutorial will walk you through setting up a user on your MySQL server to connect remotely.
    2. [RTCamp] Enabling Remote Access
      1. Solution to error:
        ERROR 1130 (HY000): Host ‘1.2.3.4’ is not allowed to connect to this MySQL server
    3. [Serverdefault] Possible Solutions for CommunicationExceptions problems.
      1. The author's advice on changing "bind-address" attribute worked for me.

No comments:

Post a Comment