Last Update: "2014/04/04 10:35:20 makoto"

databases

mysql-server

参考: http://emutyworks.com/wiki/pukiwiki.php?NetBSD
ttyp1:makoto@umax  13:37:33/050419(...databases/mysql-client)> pkg_info -D mysql-server
Information for mysql-server-4.0.24:

Install notice:
===========================================================================
$NetBSD: MESSAGE,v 1.10 2004/11/18 08:22:27 jklos Exp $

The MySQL directory `/var/mysql' should be owned by the user
`mysql' and group `mysql'.  This can be done with:

  chown -R mysql:mysql /var/mysql

If this is a new installation, you will likely want to set up the 
initial database tables by using the following command:

  /usr/pkg/bin/mysql_install_db --user=mysql

After the tables are set up and the MySQL server is running, 
please remember to set a password for the MySQL root user!
This is done by running both:

  /usr/pkg/bin/mysqladmin -u root -p password 'new-password'
  /usr/pkg/bin/mysqladmin -h `hostname` -u root -p password 'new-password'

The "Enter password:" prompt is asking for the existing password.
As there is no existing password, just press the Return key.

There is a script distributed with MySQL that can help you lock down
an installation.  This script has been installed to

  /usr/pkg/bin/mysql_secure_installation.

Please see the manual and the MySQL web site for more instructions.

===========================================================================


ttyp1:makoto@umax  13:45:20/050419(...databases/mysql-client)> 

mysql_install_db

ttyp1:makoto@umax 14:06:40/050419(...databases/mysql-client)> \ sudo chown -R mysql:mysql /var/mysql ttyp1:makoto@umax 14:06:51/050419(...databases/mysql-client)> \ sudo /usr/pkg/bin/mysql_install_db --user=mysql Preparing db table Preparing host table Preparing user table Preparing func table Preparing tables_priv table Preparing columns_priv table Installing all prepared tables 050419 14:07:06 /usr/pkg/libexec/mysqld: Shutdown Complete To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/pkg/bin/mysqladmin -u root password 'new-password' /usr/pkg/bin/mysqladmin -u root -h umax password 'new-password' See the manual for more instructions. You can start the MySQL daemon with: cd /usr/pkg ; /usr/pkg/bin/mysqld_safe & You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory: cd sql-bench ; perl run-all-tests Please report any problems with the /usr/pkg/bin/mysqlbug script! The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at https://order.mysql.com ttyp1:makoto@umax 14:07:06/050419(...databases/mysql-client)>

rc.d/mysqld

ttyp1:makoto@umax 14:07:06/050419(...databases/mysql-client)> \ sudo /usr/pkg/bin/mysqladmin -u root -p password 'hogehoge' Enter password: /usr/pkg/bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)' Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
mysqld 処理が走っていなかったので、次のようにして開始
ttyp1:makoto@umax 14:08:46/050419(...databases/mysql-client)> \ sudo cp -p /usr/pkg/share/examples/rc.d/*sql* /etc/rc.d/ ttyp1:makoto@umax 14:09:28/050419(...databases/mysql-client)> \ sudo env mysqld=YES /etc/rc.d/mysqld start Starting mysqld. ttyp1:makoto@umax 14:09:36/050419(...databases/mysql-client)>
ttyp1:makoto@umax 14:11:22/050419(...databases/mysql-client)> \ sudo /usr/pkg/bin/mysqladmin -u root -p password 'hogehoge' Enter password: (Return)
/usr/pkg/bin/mysqladmin: connect to server at 'umax' failed error: 'Host 'umax.example.com' is not allowed to connect to this MySQL server'

mysql_secure_installation

ttyp1:makoto@umax 14:13:34/050419(...databases/mysql-client)> \ sudo /usr/pkg/bin/mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): xxxxx OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] n ... skipping. By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL!
You may check if the password set above is right by:
pts/4:makoto@t-105 18:34:52/090430(~)> mysql -p -u root Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 5.0.67 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> quit Bye.
You may then need create database by mysqladmin