Changes between Version 30 and Version 31 of howto/MySQL


Ignore:
Timestamp:
May 18, 2019, 10:31:14 PM (5 years ago)
Author:
gagarine (Simon)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • howto/MySQL

    v30 v31  
    3838}}}
    3939
     40
     41Select the installed version to be the default one
     42
     43{{{
     44$ sudo port select mysql mysql57
     45}}}
     46
     47
     48
    4049== Step 2: Create a database ==
    4150
    42 Also, mysql57 now uses the `''port select''` mechanism to manage the creation of symlinks in
    43 /opt/local/bin. Using `port select` will install a link for exactly one of the available
    44 installations. Alternatively, you may simply add the path containing the desired mysql
    45 installation to your PATH.
    46 
    47 Use one of these two:
    48 
    49 {{{
    50 $ sudo port select mysql mysql57
    51 
    52 $ export PATH=$PATH:/opt/local/lib/mysql57/bin
    53 }}}
    54 
    55 Once you have done at least one of the two previous commands, set up the main database.  For MySQL 5.7:
     51
     52**For MySQL 5.7:**
    5653
    5754{{{
     
    6158Make a note of the root user password which is auto-generated.
    6259
    63 For MySQL 5.6 and earlier:
     60**For MySQL 5.6 and earlier:**
    6461
    6562{{{
     
    7774}}}
    7875
    79 == Step 3: Activate the installation ==
    80 Activate your MySQL server installation so that it autostarts when you boot your machine:
     76== Step 3: Start MySQL ==
     77
     78Activate your MySQL server so that it autostarts when you boot your machine:
    8179{{{
    8280$ sudo port load mysql57-server
     
    9795
    9896== Step 4: Set the MySQL password ==
     97
    9998Set 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):
    10099{{{
    101100$ /opt/local/lib/mysql57/bin/mysqladmin -u root -p password <new-password>
    102101}}}
     102
    103103Note: This command line form of the command will generate:
    104104 ''Warning: Using a password on the command line interface can be insecure.''
     
    107107$ /opt/local/lib/mysql57/bin/mysqladmin -u root -p password
    108108}}}
     109
    109110 ''Enter password:'' <press return> \\
    110111 ''New password:'' <new password> \\
     
    146147}}}
    147148
    148 The following is a more detailed process that may achieve the same results as the interactive program.  Place the following into {{{mysql_security.sql}}} and replace the {{{'MyNewPass'}}} with your root password.  Note that the SQL will remove all access for root from any location other than 'localhost'.  You might like to keep this SQL file - all the lines beginning with '--' are doc-comments about how to use it.
    149 
    150 Wrapper no longer exists...
    151 
    152 {{{
    153 -- HOW TO USE THIS FILE (with a MacPorts installation):
    154 
    155 --$ sudo port unload mysql57-server
    156 
    157 -- $ sudo mysqld_safe --init-file=mysql_security.sql &
    158 -- The init will terminate if there are any errors in the init file.
    159 -- Wait a bit to be sure the server is running.
    160 -- If it's running, then shutdown the server (root password required):
    161 -- $ /opt/local/bin/mysqladmin -u root -p shutdown
    162 -- Check that everything worked.  There may be an ERROR if the test database
    163 -- doesn't exist.  Otherwise there should be no errors in the file reported by
    164 -- 'mysqld_safe Logging to ..." during the mysql_safe5 startup from above:
    165 -- $ sudo tail -n 20 /opt/local/var/db/mysql5*.err
    166 
    167 UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
    168 DELETE FROM mysql.user WHERE User='root' AND Host!='localhost';
    169 DELETE FROM mysql.user WHERE User='';
    170 FLUSH PRIVILEGES;
    171 DROP DATABASE test;
    172 DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
    173 }}}
    174 
    175 The server startup options {{{--skip-networking}}} and {{{--skip-grant-tables}}} may be useful while implementing security. 
    176149
    177150See also http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html#resetting-permissions-unix
     
    188161sudo port load mysql57-server
    189162}}}
     163
    190164== Starting and stopping the MySQL server ==
    191165=== Start ===
     
    197171$ sudo port unload mysql57-server
    198172}}}
     173
    199174= Troubleshooting =
    200175see e.g. https://lists.macports.org/pipermail/macports-users/2016-July/041178.html
     176
    201177== Where are ... ==
    202178see e.g.
    203179* https://stackoverflow.com/questions/7459103/mysql-data-directory-location
     180
    204181=== Libraries and socket files ===
    205182The command