null Posted June 29, 2004 Report Share Posted June 29, 2004 (edited) This is on a stand-alone machine with FC2. I installed mysql by way of yum install mysql I have a few questions regarding getting it setup properly. During an Intro to Databases course last year, we had to install Oracle 9i / SQL on our machines at home (winblows) to do some assignments on. During my oracle install, if I remember right, I entered the username & password during install (I seem to remember "scott" and "tiger" - even though those aren't names I selected). I can't remember how the sql server was started on my winblows machine. Probably automatically at bootup. So anyway, on a linux box, how does the server get started? Is it set-up as a process that starts automatically whenever you log on, or is it started just when you want to use it? Also, how do the username & password get set-up? I don't think I'll have any trouble learning to create a Db and tables and fields and all that, I'm just not sure how to do the initial setup. edit: I did go into Server Settings / Services - from the Main Menu, but mysqld was not listed in the services listing... thanks in advance for any comments [moved from Terminal Shell, etc by spinynorman] Edited July 6, 2004 by null Quote Link to comment Share on other sites More sharing options...
armondf Posted June 29, 2004 Report Share Posted June 29, 2004 Hi there, MySql is a very powerful Database Server, and there is a huuuuuuge amount of info available all over the net. Firstly, click on over to http://www.mysql.com/ and download the documentation in whatever format you choose. Documentation for MySql is extremely good, and if you use the online documentation, the user comments will usually sort out little issues you've been struggling with. Ok, as for startup... MySql will not necessarily be running at startup. To check if you have a working mysql installation, simply type mysql at a console prompt. If you have mysql installed, then it will either connect to a running mysql server, or die with an error like "ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'". If the message is the latter, then your mysql is installed BUT not running. to start mysql, try one of the following methods: type at a console prompt: /etc/rc.d/init.d/mysqld restart If you don't have a startup script, or your startup script is broken (some of my clients using FC1/2 and MySql have broken default startup scripts for Mysql), then create/save the following codeblock as a startup file mysqld in /etc/rc.d/init.d/ #!/bin/bash # # mysqld This shell script takes care of starting and stopping # the MySQL subsystem (mysqld). # # chkconfig: - 78 12 # description: MySQL database server. # processname: mysqld # config: /etc/my.cnf # pidfile: /var/run/mysqld/mysqld.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network prog="MySQL" datadir="/var/lib/mysql" start(){ touch /var/log/mysqld.log chown mysql.mysql /var/log/mysqld.log chmod 0640 /var/log/mysqld.log if [ ! -d $datadir/mysql ]; then action $"Initializing MySQL database: " /usr/bin/mysql_install_db ret=$? chown -R mysql.mysql $datadir if [ $ret -ne 0 ]; then return $ret fi fi chown -R mysql.mysql $datadir chmod 0755 $datadir /usr/bin/safe_mysqld --defaults-file=/etc/my.cnf >/dev/null 2>&1 & ret=$? # Spin for a maximum of ten seconds waiting for the server to come up if [ $ret -eq 0 ]; then for x in 1 2 3 4 5 6 7 8 9 10; do if [ -n "`/usr/bin/mysqladmin -u mysqld ping 2> /dev/null`" ]; then break; else sleep 1; fi done if !([ -n "`/usr/bin/mysqladmin -u mysqld ping 2> /dev/null`" ]); then echo "Timeout error occurred trying to start MySQL Daemon." action $"Starting $prog: " /bin/false else action $"Starting $prog: " /bin/true fi else action $"Starting $prog: " /bin/false fi [ $ret -eq 0 ] && touch /var/lock/subsys/mysqld return $ret } stop(){ /bin/kill `cat /var/run/mysqld/mysqld.pid 2> /dev/null ` > /dev/null 2>&1 ret=$? if [ $ret -eq 0 ]; then action $"Stopping $prog: " /bin/true else action $"Stopping $prog: " /bin/false fi [ $ret -eq 0 ] && rm -f /var/lock/subsys/mysqld [ $ret -eq 0 ] && rm -f $datadir/mysql.sock return $ret } restart(){ stop start } condrestart(){ [ -e /var/lock/subsys/mysqld ] && restart || : } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status mysqld ;; restart) restart ;; condrestart) condrestart ;; *) echo $"Usage: $0 {start|stop|status|condrestart|restart}" exit 1 esac exit $? Once you've done this, and an /etc/rc.d/init.d/mysqld restart starts and runs the server, you should be able to connect to the server by running mysql from a commandline. this will give you a prompt looking like this: [root@trefdb tmp]# mysql Welcome to the MySQL monitor. Commands end with; or \g. Your MySQL connection id is 1 to server version: 3.23.54 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> if you are that far, then congrats, your mysql server is up and running. Lemme know when you're there, then we can help setting up a user, etc. Regards, Armond Quote Link to comment Share on other sites More sharing options...
Michel Posted June 29, 2004 Report Share Posted June 29, 2004 (edited) I also setted it up some time ago ... The docs on the mysql-site contain a lot of usefull stuff. If you really want to do it the graphical way ..there are quite some graphical interfaces to databases. You have ofcourse the one provided by mysql themselves, but there are others too. I haven't used any of them yet ... since it's always good to be able to do it using the commandline and you'll have all the possible options normally, while a graphical client maybe doesn't supprot all the options. I know gnome has one .. just check gnomefiles.org and kde has some too I suppose kde-apps.org You could ofcourse check also the one provided by mysql themselves. These 2/3 places will help you on your way for graphical clients ... You also have google :), sourceforge, ... Edited June 29, 2004 by Michel Quote Link to comment Share on other sites More sharing options...
null Posted June 29, 2004 Author Report Share Posted June 29, 2004 thanks for the helpful replies. Firstly, click on over to http://www.mysql.com/ I did do that, before I posted my first post To check if you have a working mysql installation, simply type mysql at a console prompt I also did that before I posted my first post... or die with an error like "ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'". If the message is the latter, then your mysql is installed BUT not running. yep, that's exactly what I got, before I posted here. That's why I knew sql was installed but the server was not running, hence my first post I'm just mentioning the above things because I didn't want people thinking I just ask questions here without doing any checking myself first. I also googled a bit on mysql, and thats how I found the mysql.com site. I did read thru the post-install steps at that site. However, I still had my questions. I will try out your script when I get home later. I never created a shell script before (although I did a lot of batch files back in my DOS days). So do I just do a vi mysqld in /etc/rc.d/init.d/ ? Also, I wonder if all my locations are the same (the directories) as in your script. I'll have to do some checking when I get home. thanks again !! Quote Link to comment Share on other sites More sharing options...
null Posted June 30, 2004 Author Report Share Posted June 30, 2004 tried the script (copied & pasted exactly as is). Getting an error on line 62 "unexpected token 'new line' line 62 is this one: /bin/kill `cat /var/run/mysqld/mysqld.pid 2> /dev/null ` > /dev/null 2>&1 Also, how do I make a shell script executable from anywhere? The only way I can run it is if I'm in the directory and do a ./mysqld If I'm anywhere else, it says not found. How do you get it in the path? Quote Link to comment Share on other sites More sharing options...
null Posted July 6, 2004 Author Report Share Posted July 6, 2004 ok, thread died quick. Had to figure it out myself... :unsure: I googled and found a helpful site quickly: http://www.siliconvalleyccie.com/linux-adv/mysql.htm Found out that even though you do a yum install mysql then you ALSO have to do a yum install mysql-server I still can't get the server starting at bootup, but I can start the server by: /etc/init.d/mysqld start and then after entering "mysql" I am greeted with the mysql> prompt. another problemo solved... B) PS: how do I delete the startup script that I copied & pasted into /etc/rc.d/init.d/ ? See 4 posts above this one. Quote Link to comment Share on other sites More sharing options...
armondf Posted July 20, 2004 Report Share Posted July 20, 2004 Hi, sorry, haven't checked this thread out in a while. What do you wanna delete? Regards, Armond Quote Link to comment Share on other sites More sharing options...
null Posted July 22, 2004 Author Report Share Posted July 22, 2004 Hi, sorry, haven't checked this thread out in a while. What do you wanna delete? <{POST_SNAPBACK}> I want to delete the startup script that you gave me back up in post # 2 of this thread. I copied & pasted it. After doing yum install mysql-server, the server starts ok. So I tried to delete your startup script, just like deleting a file, but it would not let me. Maybe I wasn't root, I can't remember. It's been awhile. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.