Changes between Version 10 and Version 11 of howto/MySQL
- Timestamp:
- Oct 9, 2016, 2:39:55 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
howto/MySQL
v10 v11 14 14 15 15 * 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. 17 18 * '''mysql55''': MySQL v5.5.x. 18 19 * '''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. … … 32 33 If you want to run a MySQL server on this computer, install MySQL like this: 33 34 {{{ 34 $ sudo port install mysql5 6-server35 $ sudo port install mysql57-server 35 36 }}} 36 37 37 38 = Step 2: Create a database = 38 39 39 Also, mysql5 6now uses the `''port select''` mechanism to manage the creation of symlinks in40 Also, mysql57 now uses the `''port select''` mechanism to manage the creation of symlinks in 40 41 /opt/local/bin. Using `port select` will install a link for exactly one of the available 41 42 installations. Alternatively, you may simply add the path containing the desired mysql … … 45 46 46 47 {{{ 47 $ sudo port select mysql mysql5 648 $ sudo port select mysql mysql57 48 49 49 $ export PATH=$PATH:/opt/local/lib/mysql5 6/bin50 $ export PATH=$PATH:/opt/local/lib/mysql57/bin 50 51 }}} 51 52 52 Once you have done at least one of the two previous commands, set up the main database: 53 Once 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 59 Make a note of the root user password which is auto-generated. 60 61 For MySQL 5.6 and earlier: 53 62 54 63 {{{ 55 64 $ 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 69 Set 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/ 59 75 }}} 60 76 … … 62 78 Activate your MySQL server installation so that it autostarts when you boot your machine: 63 79 {{{ 64 $ sudo port load mysql5 6-server80 $ sudo port load mysql57-server 65 81 }}} 66 82 … … 69 85 $ ps -ax | grep mysql 70 86 }}} 87 88 If 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 71 96 = Step 4: Set the MySQL password = 72 Set the MySQL `root` password ( it should currently be empty,see also the security option below):97 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): 73 98 {{{ 74 $ /opt/local/lib/mysql5 6/bin/mysqladmin -u root -p password <new-password>99 $ /opt/local/lib/mysql57/bin/mysqladmin -u root -p password <new-password> 75 100 }}} 76 101 Note: This command line form of the command will generate: … … 78 103 Therefore it is recommended that you use the interactive form: 79 104 {{{ 80 $ /opt/local/lib/mysql5 6/bin/mysqladmin -u root -p password105 $ /opt/local/lib/mysql57/bin/mysqladmin -u root -p password 81 106 }}} 82 107 ''Enter password:'' <press return> \\ … … 84 109 ''Confirm new password:'' <new password> 85 110 86 You will first be prompted for your existing password (''Enter password:''); since it is empty, justpress Return.\\111 You 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.\\ 87 112 Then <new-password>`is your new desired root password, followed by Return. 88 113 … … 126 151 -- HOW TO USE THIS FILE (with a MacPorts installation): 127 152 128 --$ sudo port unload mysql5 6-server153 --$ sudo port unload mysql57-server 129 154 130 155 -- $ sudo mysqld_safe --init-file=mysql_security.sql & … … 136 161 -- doesn't exist. Otherwise there should be no errors in the file reported by 137 162 -- 'mysqld_safe Logging to ..." during the mysql_safe5 startup from above: 138 -- $ sudo tail -n 20 /opt/local/var/db/mysql5 /*.err163 -- $ sudo tail -n 20 /opt/local/var/db/mysql5*.err 139 164 140 165 UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; … … 148 173 The server startup options {{{--skip-networking}}} and {{{--skip-grant-tables}}} may be useful while implementing security. 149 174 150 See also http://dev.mysql.com/doc/refman/5. 6/en/resetting-permissions.html#resetting-permissions-unix175 See also http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html#resetting-permissions-unix 151 176 152 177 … … 157 182 {{{ 158 183 man mysql_upgrade -- details on the upgrade program (man page) 159 sudo port unload mysql5 6-server160 sudo /opt/local/lib/mysql5 6/bin/mysql_upgrade -u root -p161 sudo port load mysql5 6-server184 sudo port unload mysql57-server 185 sudo /opt/local/lib/mysql57/bin/mysql_upgrade -u root -p 186 sudo port load mysql57-server 162 187 }}} 163 188 == Starting and stopping the MySQL server == 164 189 === Start === 165 190 {{{ 166 $ sudo port load mysql5 6-server191 $ sudo port load mysql57-server 167 192 }}} 168 193 === Stop === 169 194 {{{ 170 $ sudo port unload mysql5 6-server195 $ sudo port unload mysql57-server 171 196 }}} 172 197