Changes between Version 30 and Version 31 of howto/MySQL
- Timestamp:
- May 18, 2019, 10:31:14 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
howto/MySQL
v30 v31 38 38 }}} 39 39 40 41 Select the installed version to be the default one 42 43 {{{ 44 $ sudo port select mysql mysql57 45 }}} 46 47 48 40 49 == Step 2: Create a database == 41 50 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:** 56 53 57 54 {{{ … … 61 58 Make a note of the root user password which is auto-generated. 62 59 63 For MySQL 5.6 and earlier: 60 **For MySQL 5.6 and earlier:** 64 61 65 62 {{{ … … 77 74 }}} 78 75 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 78 Activate your MySQL server so that it autostarts when you boot your machine: 81 79 {{{ 82 80 $ sudo port load mysql57-server … … 97 95 98 96 == Step 4: Set the MySQL password == 97 99 98 Set 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): 100 99 {{{ 101 100 $ /opt/local/lib/mysql57/bin/mysqladmin -u root -p password <new-password> 102 101 }}} 102 103 103 Note: This command line form of the command will generate: 104 104 ''Warning: Using a password on the command line interface can be insecure.'' … … 107 107 $ /opt/local/lib/mysql57/bin/mysqladmin -u root -p password 108 108 }}} 109 109 110 ''Enter password:'' <press return> \\ 110 111 ''New password:'' <new password> \\ … … 146 147 }}} 147 148 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-server156 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 shutdown162 -- Check that everything worked. There may be an ERROR if the test database163 -- doesn't exist. Otherwise there should be no errors in the file reported by164 -- 'mysqld_safe Logging to ..." during the mysql_safe5 startup from above:165 -- $ sudo tail -n 20 /opt/local/var/db/mysql5*.err166 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.176 149 177 150 See also http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html#resetting-permissions-unix … … 188 161 sudo port load mysql57-server 189 162 }}} 163 190 164 == Starting and stopping the MySQL server == 191 165 === Start === … … 197 171 $ sudo port unload mysql57-server 198 172 }}} 173 199 174 = Troubleshooting = 200 175 see e.g. https://lists.macports.org/pipermail/macports-users/2016-July/041178.html 176 201 177 == Where are ... == 202 178 see e.g. 203 179 * https://stackoverflow.com/questions/7459103/mysql-data-directory-location 180 204 181 === Libraries and socket files === 205 182 The command