LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-06-2007, 04:49 AM   #1
rn5a
Member
 
Registered: Aug 2007
Posts: 48

Rep: Reputation: 15
Question Now It´s MySQL´s Turn!


I am having problems in running mysqladmin. After installing MySQL, these are the instructions the help file:
Quote:
2. If necessary, run the mysql_install_db program to set up the initial MySQL grant tables containing the privileges that determine how users are allowed to connect to the server. You'll need to do this if you used a distribution type for which the installation procedure doesn't run the program for you.

Typically, mysql_install_db needs to be run only the first time you install MySQL, so you can skip this step if you are upgrading an existing installation, However, mysql_install_db does not overwrite any existing privilege tables, so it should be safe to run in any circumstances.

To initialize the grant tables, use one of the following commands, depending on whether mysql_install_db is located in the bin or scripts directory:

shell> bin/mysql_install_db --user=mysql
shell> scripts/mysql_install_db --user=mysql

The mysql_install_db script creates the server's data directory. Under the data directory, it creates directories for the mysql database that holds all database privileges and the test database that you can use to test MySQL. The script also creates privilege table entries for root and anonymous-user accounts. The accounts have no passwords initially. A description of their initial privileges is given in Section 2.4.16.3, “Securing the Initial MySQL Accounts”. Briefly, these privileges allow the MySQL root user to do anything, and allow anybody to create or use databases with a name of test or starting with test_.

It is important to make sure that the database directories and files are owned by the mysql login account so that the server has read and write access to them when you run it later. To ensure this, the --user option should be used as shown if you run mysql_install_db as root. Otherwise, you should execute the script while logged in as mysql, in which case you can omit the --user option from the command.

mysql_install_db creates several tables in the mysql database, including user, db, host, tables_priv, columns_priv, func, and others. See Section 5.7, “The MySQL Access Privilege System”, for a complete listing and description of these tables.

If you don't want to have the test database, you can remove it with mysqladmin -u root drop test after starting the server.

If you have trouble with mysql_install_db at this point, see Section 2.4.16.2.1, “Problems Running mysql_install_db”.


3. Start the MySQL server:

shell> bin/mysqld_safe --user=mysql &

It is important that the MySQL server be run using an unprivileged (non-root) login account. To ensure this, the --user option should be used as shown if you run mysql_safe as system root. Otherwise, you should execute the script while logged in to the system as mysql, in which case you can omit the --user option from the command.

Further instructions for running MySQL as an unprivileged user are given in Section 5.6.5, “How to Run MySQL as a Normal User”.

If you neglected to create the grant tables before proceeding to this step, the following message appears in the error log file when you start the server:

mysqld: Can't find file: 'host.frm'

If you have other problems starting the server, see Section 2.4.16.2.3, “Starting and Troubleshooting the MySQL Server”.


4. Use mysqladmin to verify that the server is running. The following commands provide simple tests to check whether the server is up and responding to connections:

shell> bin/mysqladmin version
shell> bin/mysqladmin variables

The output from mysqladmin version varies slightly depending on your platform and version of MySQL, but should be similar to that shown here:

shell> bin/mysqladmin version
mysqladmin Ver 14.12 Distrib 5.0.46, for pc-linux-gnu on i686
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version 5.0.46
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 14 days 5 hours 5 min 21 sec

Threads: 1 Questions: 366 Slow queries: 0
Opens: 0 Flush tables: 1 Open tables: 19
Queries per second avg: 0.000

To see what else you can do with mysqladmin, invoke it with the --help option.
I executeted the instructions given till the 3rd step. The problem comes in the 4th step. In the 3rd step, I executed the command

bin/mysqld_safe --user=mysql &

The above command produces the following output:

# Starting mysqld daemon with databases from /var/lib/mysql
STOPPING server from pid file /var/lib/mysql/localhost.pid
070906 15:12:01 mysqld ended


after which the next prompt # (I logged in as the root user) doesn´t come up only. So how can the command

bin/mysqladmin version

be executed as the next # prompt doesn´t come up only?

I am getting confused!

Thanks,

Ron
 
Old 09-06-2007, 05:11 AM   #2
dark_angel
Member
 
Registered: Oct 2006
Location: Bacolod, Philippines
Distribution: Slackware 12
Posts: 62

Rep: Reputation: 15
the prompt is there, only you cannot see the #. it came up the moment mysqld stopped. just type "clear" to clear the screen.

it looks like the mysql server didn't start. i guess it cannot access the installed database. this happens when you run mysql_install_db as root. you should switch to user mysql before running mysql_install_db.

#su mysql
$mysql_install_db

good luck!

Last edited by dark_angel; 09-06-2007 at 05:12 AM.
 
Old 09-07-2007, 04:27 AM   #3
rn5a
Member
 
Registered: Aug 2007
Posts: 48

Original Poster
Rep: Reputation: 15
Dark_angel, could you please tell me how do I change to mysql user from the Konsole so that I can run mysql_install_db?

Thanks,

Regards,

Ron
 
Old 09-07-2007, 04:33 AM   #4
rn5a
Member
 
Registered: Aug 2007
Posts: 48

Original Poster
Rep: Reputation: 15
Oh! I am so very sorry to ask the last question...sorry...I didn´t notice it.

Sorry once again,

Thanks,

Regards,

Ron
 
Old 09-07-2007, 05:09 AM   #5
rn5a
Member
 
Registered: Aug 2007
Posts: 48

Original Poster
Rep: Reputation: 15
Dark_angel, it´s still not working. What I did is this:

1. Opened a Terminal Window & logged in as the root using su after which I logged in as the mysql user as you suggested after which the prompt changed to bash-3.15 from [root@localhost ronnie]#. The reason why I am logging in as root first is because if I directly try to login as the mysql user in the Terminal Window without logging in as root, then after entering su mysql, I am being asked for password! But I have never set any password for user mysql since I have never been asked to set a password for user mysql.

2. Next I navigated to usr/bin where mysql_install_db resides by typing cd usr/bin.

3. Next I typed mysql_install_db. This is the output:

Installing MySQL system tables...
070907 15:12:08 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
070907 15:12:08 [Warning] Can't create test file /var/lib/mysql/localhost.lower-test
ERROR: 1347 'mysql.db' is not BASE TABLE
070907 15:12:09 [ERROR] Aborting

070907 15:12:09 [Note] /usr/sbin/mysqld: Shutdown complete

Installation of system tables failed!

Examine the logs in /var/lib/mysql for more information.
You can try to start the mysqld daemon with:
/usr/sbin/mysqld --skip-grant &
and use the command line tool
/usr/bin/mysql to connect to the mysql
database and look at the grant tables:

shell> /usr/bin/mysql -u root mysql
mysql> show tables

Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in /var/lib/mysql that may be helpful.

The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the /usr/bin/mysqlbug script
.

The documentation says that running mysql_install_db creates several databases in the mysql database including user, db, host, tables_priv, columns_priv, func and others. These databases do exist in a directory named mysql which exists in the /var/lib/mysql directory but all these databases are locked (the icons are accompanied with a lock image). Even a database named test (which is actually a directory in /var/lib/mysql) gets created but it´s empty.

4. After this, I repeated the steps about which I have mentioned in my first post but the outcome remains the same.

Please help me install MySQL.

One more point - since I am facing so many problems in installing MySQL, I decided to uninstall the MySQL server & client. So logging in as the root user, I navigated to the directory in which the 2 RPMs exist & entered the following commands one after the other:

rpm -e MySQL-server-5.0.45-0.glibc23.i386.rpm

rpm -e MySQL-client-5.0.45-0.glibc23.i386.rpm


Strangely the outcome of both the commands said that the packages are not installed! But when I try to re-install, the output says that the packages are already installed!

Thanks,

Regards,

Ron

Last edited by rn5a; 09-07-2007 at 05:16 AM.
 
Old 09-07-2007, 06:14 AM   #6
dark_angel
Member
 
Registered: Oct 2006
Location: Bacolod, Philippines
Distribution: Slackware 12
Posts: 62

Rep: Reputation: 15
here's an except from the manual. maybe this can help.

--------------------------------------------------------------------------------------------
6. Ensure that the distribution contents are accessible to mysql. If you unpacked the distribution as mysql, no further action is required. If you unpacked the distribution as root, its contents will be owned by root. Change its ownership to mysql by executing the following commands as root in the installation directory:

shell> chown -R mysql .
shell> chgrp -R mysql .

The first command changes the owner attribute of the files to the mysql user. The second changes the group attribute to the mysql group.

7. If you have not installed MySQL before, you must create the MySQL data directory and initialize the grant tables:

shell> scripts/mysql_install_db --user=mysql

If you run the command as root, include the --user option as shown. If you run the command while logged in as that user, you can omit the --user option. The command should create the data directory and its contents with mysql as the owner. After creating or updating the grant tables, you need to restart the server manually.
--------------------------------------------------------------------------------------------

with regards to your install/uninstall problem, i have no idea since my distro is not using rpm. in the past, i have resorted to manual deletion of packages but i won't recommend it in your case since our distros differ in how they handle packages. you should start another thread about it.

good luck

Last edited by dark_angel; 09-07-2007 at 06:16 AM.
 
Old 09-07-2007, 02:49 PM   #7
rn5a
Member
 
Registered: Aug 2007
Posts: 48

Original Poster
Rep: Reputation: 15
Dark_Angel, I executed all the steps that you have mentioned but I still encounter the same problems. Moreover it´s documented in the help file that if MySQL is installed from RPM, then mysql_install_db gets executed automatically. So even before I manually executed mysql_install_db, mysql_install_db already got executed which I am sure of because the database mysql with the databases like host, tables_priv, columns_priv already got created before I ran mysql_install_db.

The problem is when I run

mysqld_safe --user=mysql &

It says that mysqld has ended about which I have mentioned in my first post but the help file tells to run mysqladmin version after running the above command! Now when mysqld has already ended, how will mysqladmin version run?

Do you get the message mysqld has ended when you run mysqld_safe --user=mysql &? Moreover, when you go to the mysql database (which is located in /var/lib in my machine), do you find the mysql database locked?

Also the user & group of the different files related to MySQL in usr/bin like mysql, mysqladmin, mysqld_safe, mysql_install_db should be mysql, isn´t it?

Please, dark_angel, please help me resolve this! I am really having a tough time. After going through a harrowing experience installing PHP, I thought my travails will be over but I was so very wrong.

I guess the ease with which softwares can be installed in Windows is one of the reasons why 90% of PC users all over the world use Windows & not Linux. After all, who has got so much time to just install softwares? I had to devote almost 5 days to install PHP & now it´s MySQL! If it takes me 10 days just to install MySQL & PHP, I wonder how much time will it take me to learn them!

Thanks,

Regards,

Ron
 
Old 09-07-2007, 04:00 PM   #8
rn5a
Member
 
Registered: Aug 2007
Posts: 48

Original Poster
Rep: Reputation: 15
Dark_angel, I managed to start the MySQL daemon by opening a Terminal Window, logging in as the root user, navigating to the directory /usr/bin & then running

mysqld_safe -user=mysql

This said Starting mysqld daemon with databases from /var/lib/mysql

What do I do after that? The reason I am asking this is because after the above message comes up, if I enter any command in that Terminal Window, the command doesn´t get executed. So how do I proceed further?

Actually I am using a GUI tool named MySQL Administrator so that I can work with MySQL databases but I am asked for Server Hostname, Username & Password.

At the time of logging into Linux when I am asked to enter my username & password, it shows a message saying Welcome to localhost but after entering the username & password (both of which are ronnie), the next screen says Welcome ronnie. So what´s the server hostname for MySQL? Is it localhost or ronnie? The Username is mysql, if I am not mistaken, but what´s the password? Do I have to set a password for mysql user?
 
Old 09-08-2007, 06:31 AM   #9
rn5a
Member
 
Registered: Aug 2007
Posts: 48

Original Poster
Rep: Reputation: 15
LAMP installation refuses to settle me down!

Well I managed to start MySQL as well as MySQL Administrator by running this command:

mysqld_safe --stop-grant-tables --user=root &

Was very happy that I finally could make it work but alas, now PHP which I had installed successfully before, refuses to run! Apache starts successfully but when I try to run a PHP file in FireFox, it says:

Unable to establish a connection to the server at localhost.

I reconfigured PHP again but no result! Now can someone please help me overcome this problem?

It´s really getting too much!
 
Old 09-08-2007, 07:21 AM   #10
tanveer
Member
 
Registered: Feb 2004
Location: e@rth
Distribution: RHEL-3/4/5,Gloria,opensolaris
Posts: 525

Rep: Reputation: 37
Hi there,

Why run mysql as root? Please follow the steps as below and thats also written in INSTALL-BINARY file. Just download the mysql version say for example : mysql-standard-5.0.27-lilnux-i686.tar.gz and follow the below steps.

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -
shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &

Did you compiled apache? Can u see the default index page of apache and does this error comes when you try to connect to your mysql database?
 
Old 09-08-2007, 08:05 AM   #11
dark_angel
Member
 
Registered: Oct 2006
Location: Bacolod, Philippines
Distribution: Slackware 12
Posts: 62

Rep: Reputation: 15
sorry for the late reply.

the command "mysql_safe --user=mysql &" starts the mysql daemon as the user mysql and then puts it in the background. you already have the commandline back after executing this command. just clear the screen. never forget the "&" since it tells bash to run the application at the background.

if the mysql server is already running, the first thing that you should do is change the password of root. enter this command:

#mysqladmin -u root -p password "your new password"

it will ask for a password but just press enter since by default (i think) root has no password. you should then log-in to the mysql server to add new accounts since it's not wise to always use root. you can to this either at the console or via third party softwares like phpMyAdmin or ,yes, MYSQL Administrator.

the server hostname is the name which the mysql server identifies itself. it should be localhost by default. since you haven't added new accounts yet, you can only log-in with the user root. actually there are other accounts other than root that were created upon running mysql_install_db but i don't know any of them or what they are for since i don't use them. you should look at the manual to verify this.

if you want to log-in via commandline, enter

#mysql -u root -p

it should ask for root's password. enter the password which you have created earlier. take note that i didn't specify any hostname since by default the mysql client will log-in to the mysql server with the hostname set to localhost. you will then be given a new prompt. this is where you type commands to be executed by the server. here's an example from the manual on how to add new accounts with the "grant" command:

----------------------------------------------------------------------------------------------------------------------------------

After connecting to the server as root, you can add new accounts. The following statements use GRANT to set up four new accounts:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
mysql> GRANT USAGE ON *.* TO 'dummy'@'localhost';

The accounts created by these GRANT statements have the following properties:
? Two of the accounts have a username of monty and a password of some_pass. Both accounts are superuser accounts with full
privileges to do anything. One account ('monty'@'localhost') can be used only when connecting from the local host. The
other ('monty'@'%') can be used to connect from any other host. Note that it is necessary to have both accounts for monty to be
able to connect from anywhere as monty. Without the localhost account, the anonymous-user account for localhost that is
created by mysql_install_db would take precedence when monty connects from the local host. As a result, monty would be
treated as an anonymous user. The reason for this is that the anonymous-user account has a more specific Host column value than
the 'monty'@'%' account and thus comes earlier in the user table sort order. (user table sorting is discussed in Section 5.7.5,
?Access Control, Stage 1: Connection Verification?.)
? One account has a username of admin and no password. This account can be used only by connecting from the local host. It is
granted the RELOAD and PROCESS administrative privileges. These privileges allow the admin user to execute the mysqladmin
reload, mysqladmin refresh, and mysqladmin flush-xxx commands, as well as mysqladmin processlist .
No privileges are granted for accessing any databases. You could add such privileges later by issuing additional GRANT statements.
? One account has a username of dummy and no password. This account can be used only by connecting from the local host. No priv-
ileges are granted. The USAGE privilege in the GRANT statement enables you to create an account without giving it any privileges. It
has the effect of setting all the global privileges to 'N'. It is assumed that you will grant specific privileges to the account later.
? The statements that create accounts with no password will fail if the NO_AUTO_CREATE_USER SQL mode is enabled. To deal
with this, use an IDENTIFIED BY clause that specifies a non-empty password.

------------------------------------------------------------------------------------------------------------------------------------

or you could add new accounts via MYSQL Administrator since you already have it installed. log-in as user "root" with hostname set to "localhost".

i hope this helps. good luck!
 
Old 09-08-2007, 08:19 AM   #12
dark_angel
Member
 
Registered: Oct 2006
Location: Bacolod, Philippines
Distribution: Slackware 12
Posts: 62

Rep: Reputation: 15
just a suggestion if you don't mind.

since your obviously putting up a webserver (Apache, PHP, MYSQL), why not try XAMPP. it already has everything you need and it is already configured. just download the package from their website ( http://www.apachefriends.org/en/xampp.html ), install it, and that's it. your server is ready to use without the hassle of configuring Apache, PHP, and MYSQL separately. i started with XAMPP before. it gives you convenience at the expense of just knowing a little of what's going on underneath.

as to your apache problem, can you see the default index page? if you can, that means apache is up and running. check the permissions of your php scripts. they should all be 755.
 
Old 09-08-2007, 07:32 PM   #13
rn5a
Member
 
Registered: Aug 2007
Posts: 48

Original Poster
Rep: Reputation: 15
Quote:
sorry for the late reply.
No problem, dark_angel. You have tried to help me a lot & I really appreciate that. Of course, this doesn´t mean that I am trying to undermine the help forwarded to me by others. Thanks a lot.

Quote:
just a suggestion if you don't mind.

since your obviously putting up a webserver (Apache, PHP, MYSQL), why not try XAMPP. it already has everything you need and it is already configured.
No doubt that the suggestion you have given is a very good one but XAMPP´s 51MB size is the problem. My ISP imposes restriction on the amount of data I download. The bigger problem is I frequently get disconnected from the Net & the in-built FireFox Download Manager doesn´t give the option of resuming downloads though it claims to give this option.

I also tried download managers that support resuming like WGet & D4X but like FireFox´s download manager, they don´t support resuming broken downloads whole-heartedly though they claim that they support resuming. I could manage to download almost 50% of XAMPP using D4X which involved many resumptions but I don´t know why on one occasion, it dumped the 50% download it had done & started downloading from the very beginning. Right now, I am trying Aria download manager. It says that it is downloading but the progress bar indicates 0% has been downloaded!

Can you suggest some other download managers that support resuming broken downloads?

I don´t know why after installing MySQL, PHP scripts refuse to run! FireFox prompts me to open or save to disk when I run PHP scripts! I had overcome this problem but after installing MySQL, it has erupted again! I haven´t tried the MySQL installation steps you & Tanveer have suggested since I am presently trying to make PHP scripts run....will try them out after fixing the PHP issue....
 
Old 09-09-2007, 01:08 AM   #14
tanveer
Member
 
Registered: Feb 2004
Location: e@rth
Distribution: RHEL-3/4/5,Gloria,opensolaris
Posts: 525

Rep: Reputation: 37
I found this link very useful. Better give it a try.
http://lamphowto.com/
 
Old 09-09-2007, 05:56 AM   #15
dark_angel
Member
 
Registered: Oct 2006
Location: Bacolod, Philippines
Distribution: Slackware 12
Posts: 62

Rep: Reputation: 15
this is just a suggestion. try downloading xampp via peer-to-peer softwares like bittorrent. it's a lot faster. i found a torrent file of xampp here: http://www.mybittorrent.com/info/872106/.

thanks for the LAMP howto tanveer. i'll surely be reading that one.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mysql - port 3306 - turn it off rjcrews Linux - Security 5 01-11-2007 12:18 PM
turn pc into webserver with ready-to-go linux + apache/mysql/php installer crz_06 Linux - Newbie 5 01-14-2006 09:08 PM
How to start, stop, turn on, and turn off deamons BuckRogers01 Debian 3 08-16-2005 09:39 AM
How do i turn php and mysql on? jp2 Linux - Newbie 2 09-14-2004 05:42 PM
How to turn off Xserver in the gui and turn it off in the command line geminiviper Linux - Newbie 8 08-20-2004 08:05 AM


All times are GMT -5. The time now is 09:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration