Changes between Version 10 and Version 11 of howto/MySQL


Ignore:
Timestamp:
Oct 9, 2016, 2:39:55 AM (14 months ago)
Author:
billc_lists@…
Comment:

Updated to include MySQL 5.7

Legend:

Unmodified
Added
Removed
Modified
  • howto/MySQL

    v10 v11  
    1414
    1515* MySQL
    16   * '''mysql56''': MySQL v5.6.x. This is the latest stable version of MySQL.
     16  * '''mysql57''': MySQL v5.7.x. This is the latest stable version of MySQL.
     17  * '''mysql56''': MySQL v5.6.x.
    1718  * '''mysql55''': MySQL v5.5.x.
    1819  * '''mysql51''': MySQL v5.1.x. This version reached [https://www.mysql.com/support/eol-notice.html end of life] at the end of 2013 and is therefore no longer recommended.
     
    3233If you want to run a MySQL server on this computer, install MySQL like this:
    3334{{{
    34 $ sudo port install mysql56-server
     35$ sudo port install mysql57-server
    3536}}}
    3637
    3738= Step 2: Create a database =
    3839
    39 Also, mysql56 now uses the `''port select''` mechanism to manage the creation of symlinks in
     40Also, mysql57 now uses the `''port select''` mechanism to manage the creation of symlinks in
    4041/opt/local/bin. Using `port select` will install a link for exactly one of the available
    4142installations. Alternatively, you may simply add the path containing the desired mysql
     
    4546
    4647{{{
    47 $ sudo port select mysql mysql56
     48$ sudo port select mysql mysql57
    4849
    49 $ export PATH=$PATH:/opt/local/lib/mysql56/bin
     50$ export PATH=$PATH:/opt/local/lib/mysql57/bin
    5051}}}
    5152
    52 Once you have done at least one of the two previous commands, set up the main database:
     53Once you have done at least one of the two previous commands, set up the main database.  For MySQL 5.7:
     54
     55{{{
     56$ sudo /opt/local/lib/mysql57/bin/mysqld --initialize --user=_mysql
     57}}}
     58
     59Make a note of the root user password which is auto-generated.
     60
     61For MySQL 5.6 and earlier:
    5362
    5463{{{
    5564$ sudo -u _mysql mysql_install_db
    56 $ sudo chown -R _mysql:_mysql /opt/local/var/db/mysql56/
    57 $ sudo chown -R _mysql:_mysql /opt/local/var/run/mysql56/
    58 $ sudo chown -R _mysql:_mysql /opt/local/var/log/mysql56/
     65}}}
     66
     67(initial password is blank for MySQL 5.6 and earlier)
     68
     69Set the owner:
     70
     71{{{
     72$ sudo chown -R _mysql:_mysql /opt/local/var/db/mysql57/
     73$ sudo chown -R _mysql:_mysql /opt/local/var/run/mysql57/
     74$ sudo chown -R _mysql:_mysql /opt/local/var/log/mysql57/
    5975}}}
    6076
     
    6278Activate your MySQL server installation so that it autostarts when you boot your machine:
    6379{{{
    64 $ sudo port load mysql56-server
     80$ sudo port load mysql57-server
    6581}}}
    6682
     
    6985$ ps -ax | grep mysql
    7086}}}
     87
     88If running, the command will return something like:
     89
     90{{{
     91     /opt/local/bin/daemondo --label=mysql57-server --start-cmd /opt/local/lib/mysql57/bin/mysqld --user=_mysql ; --pid=exec
     92     /opt/local/lib/mysql57/bin/mysqld --user=_mysql
     93     grep mysql
     94}}}
     95
    7196= Step 4: Set the MySQL password =
    72 Set the MySQL `root` password (it should currently be empty, see also the security option below):
     97Set the MySQL `root` password (use the auto-generated password from the --initialize command above for MySQL 5.7.  For MySQL 5.6 and earlier the password should currently be empty; see also the security option below):
    7398{{{
    74 $ /opt/local/lib/mysql56/bin/mysqladmin -u root -p password <new-password>
     99$ /opt/local/lib/mysql57/bin/mysqladmin -u root -p password <new-password>
    75100}}}
    76101Note: This command line form of the command will generate:
     
    78103Therefore it is recommended that you use the interactive form:
    79104{{{
    80 $ /opt/local/lib/mysql56/bin/mysqladmin -u root -p password
     105$ /opt/local/lib/mysql57/bin/mysqladmin -u root -p password
    81106}}}
    82107 ''Enter password:'' <press return> \\
     
    84109 ''Confirm new password:'' <new password>
    85110
    86 You will first be prompted for your existing password (''Enter password:''); since it is empty, just press Return.\\
     111You will first be prompted for your existing password (''Enter password:''); enter the root password (auto generated or no entry depending on your MySQL version) then press Return.\\
    87112Then  <new-password>`is your new desired root password, followed by Return.
    88113
     
    126151-- HOW TO USE THIS FILE (with a MacPorts installation):
    127152
    128 --$ sudo port unload mysql56-server
     153--$ sudo port unload mysql57-server
    129154
    130155-- $ sudo mysqld_safe --init-file=mysql_security.sql &
     
    136161-- doesn't exist.  Otherwise there should be no errors in the file reported by
    137162-- 'mysqld_safe Logging to ..." during the mysql_safe5 startup from above:
    138 -- $ sudo tail -n 20 /opt/local/var/db/mysql5/*.err
     163-- $ sudo tail -n 20 /opt/local/var/db/mysql5*.err
    139164
    140165UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
     
    148173The server startup options {{{--skip-networking}}} and {{{--skip-grant-tables}}} may be useful while implementing security. 
    149174
    150 See also http://dev.mysql.com/doc/refman/5.6/en/resetting-permissions.html#resetting-permissions-unix
     175See also http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html#resetting-permissions-unix
    151176
    152177
     
    157182{{{
    158183man mysql_upgrade  -- details on the upgrade program (man page)
    159 sudo port unload mysql56-server
    160 sudo /opt/local/lib/mysql56/bin/mysql_upgrade -u root -p
    161 sudo port load mysql56-server
     184sudo port unload mysql57-server
     185sudo /opt/local/lib/mysql57/bin/mysql_upgrade -u root -p
     186sudo port load mysql57-server
    162187}}}
    163188== Starting and stopping the MySQL server ==
    164189=== Start ===
    165190{{{
    166 $ sudo port load mysql56-server
     191$ sudo port load mysql57-server
    167192}}}
    168193=== Stop ===
    169194{{{
    170 $ sudo port unload mysql56-server
     195$ sudo port unload mysql57-server
    171196}}}
    172197