The Open Source Swiss Army Knife

/sql_servers/mysql/
/sql_servers/mysql/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /sql_servers   /mysql 
Permalink: mysql_install.htm
Title: add
article options : please login   |  print view

installing mysql

    1. one instance
    2. two or more instances
    3. how to

introduction

There are a few steps in getting up and running with the server. You need of course to first to install the server from source/binary. Then, you will have to figure out why it keeps dying right after you start it. Help for these steps comes from the manual which comes with the distribution and also is avaliable at their web site, www.mysql.org; the web site has a searchable version which can be helpful.

After the server is installed, you will be able to communicate with the server in a few different ways. Remote users and client GUIs can communicate via TCP/IP port (default port is 3306). Users comfortable with command line SQL may communicate with the server via the mysql command-line utility. This can be invoked with "mysql". Another way to communicate with the server is via the mysqladmin utility.

In choosing to install a linux server you will have to do some configuration at the onset. After the setup, then finally you can worry about SQL syntax and commands.

unpacking

the following are the rpm I put on the redhat: mysqlclient10-3.23.22-4, mysql-3.23.36-1, mysql-server-3.23.36-1, mysql-devel-3.23.36-1. the server is not included in the mysql package, then.

After installing MySQL, you set up the initial access privileges by running scripts/mysql_install_db.

permissions must be set up as documented at mysql.com

you need then, after setting permissions, run 'mysql_install_db'

then, do safe_mysqld

mysql_install_db

  1. [root@first log]# tail -f mysqld.log
    0x80b89b5
    0x4007c825
    0x401c445a
    New value of ebp failed sanity check, terminating backtrace!
    020414 23:02:25 mysqld started
    020414 23:02:27 /usr/libexec/mysqld: Table 'mysql.host' doesn't exist
    020414 23:02:27 /usr/libexec/mysqld: Normal shutdown
    020414 23:02:27 mysqld ended
  2. (as root) I ran 'scripts/mysql_install_db --datadir=/proj/webamt/rel/mysqldb' and then 'bin/safe_mysqld --user=mysql --datadir=/proj/webamt/rel/mysqldb &' and the following error was reported in the log file (/proj/webamt/rel/mysqldb/amthq2.err):
    020415 11:33:39 mysqld started
    020415 11:33:39 /data/mysql/3.23.47/SunOS_5.8/bin/mysqld: Can't find file: './mysql/host.frm' (errno: 13)
    020415 11:33:39 mysqld ended

    Error code 13 means that your *nix user has no permissions on MySQL data dir.
    Try: chown -R mysql.mysql /proj/webamt/rel/mysqldb
  3. there is also a good hinat at (I only got through this by doing it word for word). mysql web site.

safe_mysqld

you need to run /bin/safe_mysqld this to start and stop the database server, after installing the mysql databases.

safe_mysqld is a bash shell script which controls the MySQL daemon. Use "locate safe_mysqld" to find it, that is, unless you just unpackaged and unzipped because that such a new file won't yet be in the locate database. On this RedHat system, it is in /usr/bin so can be started by typing the name. It takes no arguments, and starts the daemon.

it's a long shell script

instead of invoking mysqld diretctly, if this script is used, safe_mysqld will restart it if it crashes

/usr/local/mysql/bin/safe_mysqld &

to use safe_mysqld, it takes some arguments: to see what your defaults are it's bin/my_print_defaults --config-file=my client mysql which assumes my.cnf is in its default location.

[root@www2 mysql2]# bin/my_print_defaults --defaults-extra-file=etc/my.cnf --config-file=my client mysql
--password=crazyboy333
--port=3306
--socket=/var/lib/mysql/mysql.sock
[root@www2 mysql2]#

these values are from /etc/my.cnf.

a startup script in /etc/rc.d/init.d/ mysql.server
invokes /usr/libexec/mysqld

connecting to the instance

from some guy's web site, deal with the problem I got every single time I reinstalled: "cannot connect through socket tmp.mysql."
You have to set an environment variable.

first, verify the daemon is really running with a mysqladmin ping.

you can connect to the running daemon with the mysql command-utility.

setting root password

problems
Here is the solution to "Access denied for user: '@unknown' to database mysql" an initial problem as found on here on the mysql web site:
"The server should let you connect because the MySQL root user has no password initially. That is also a security risk, so setting the root password is something you should do while you're setting up your other MySQL users. If you try to connect as root and get this error (above) this means that you don't have an entry in the user table with a User column value of 'root' and that mysqld cannot resolve the hostname for your client. In this case, you must restart the server with the --skip-grant-tables option and edit your `/etc/hosts' or `\windows\hosts' file to add an entry for your host."

when you first started the daemon you ran mysql_install_db. This should set up an access table for you. When you first start up the daemon you will use the --skip-grant-tables option. This option " causes the server not to use the privilege system at all. This gives everyone full access to all databases!

you are greeted during the installation of mysql_install_db with a reminder to change the root password.

It is best to add a user's password with the mysqladmin utility: /usr/bin/mysqladmin -u root -h first.sirfsup.com -p password 'new-password'
. Do not enter the password as plain-text, as the password in the database is encrypted using the PASSWORD(secret) function. If you try to use SQL to add the password you may encounter some difficulties. the syntax should be UPDATE user SET Password=PASSWORD('new_password') WHERE USER= 'joe_shmoe'.

adding users

after adding a user with mysqladimin, start the mysql daemon and edit the permissions for the user with sql commands.

granting and revoking permissions to users

modifying the grant tables, the columns are pretty self-explanatory. You can give users grant access, which means they can give their rights to others. Also, you can specify if they require a password to connect.

If you modify the grant tables manually (using INSERT, UPDATE, etc.), you should execute a FLUSH PRIVILEGES statement or run mysqladmin flush-privileges or mysqladmin reload. These commands tell the server to reload the grant tables. Otherwise your changes will have no effect until you restart the server. If you change the grant tables manually but forget to reload the privileges, you will be wondering why your changes don't seem to make any difference! However, "Modifications to the grant tables that you perform using GRANT, REVOKE, or SET PASSWORD are noticed by the server immediately". Otherwise, when the server notices that the grant tables have been changed, existing client connections are affected as follows:

  • Table and column privilege changes take effect with the client's next request.
  • Database privilege changes take effect at the next USE db_name command.

Global privilege changes and password changes take effect the next time the client connects.

also see the section below on mysqlaccess which is a script which checks permissions.

how to install two or more instances one machines

web site says the easiest way is to compile the program to listen on a different port and socket. (section 4.1.4). IN section 4.7.3 is mysqld_multi. The shell command is on the web page, it's giving the arguemnts to configure that's kind of unique.
[root@www2 mysql-4.0.9-gamma]# ./configure --with-tcp-port=3307 --with-unix-socket-path=/usr/local/mysql-4.0.9/data --prefix=/usr/local/mysql-4.0.9

Leave a Reply
Your Name:     anonymous
Your Email:
Website:  
Comments:

The author will be notified of your reply.
return to top