MySql Order by command..

Guys I am developing a forum, the thing is i want to call the sql data base saved data according to user accessed order....
Can any one help me out to solve this problem pls pls pls,,,,,,

This has nothing to do with JDBC. Likely you need to read some basic SQL tutorials.
Start off here: http://www.google.com/search?q=sql+tutorial
And MySQL specific: http://www.google.com/search?q=mysql+sql+tutorial
Once you have a real JDBC problem (once more again: JDBC != SQL), you're welcome.
The topicstart doesn't need to be all in bold though. Putting pressure by "pls pls pls" is also completely meaningless. Ask smart questions.

Similar Messages

  • How to access the mysql using ordinary command line in Azure Website?

    Hi
    I deploying Django project on Azure. I created project and MySQL db according this method: https://pytools.codeplex.com/wikipage?title=PollsDjangoSql . I can create tables using django command "syncdb" in Visual Studio. I see
    db structure in SQL Explorer. All works. But now I need to get access directly to mysql.  For example with a view to set encoding of some column, or set permissions, change user password, etc.
    I found about many different tools and methods in Microsoft portal. But the purpose of these tools, how to install it and how to use it is a very entangled (After several attempts to find out what's what two weeks later I found on my computer
    three dozen programs with unknown purpose. I doubt that I need to install so many tools to just add the user in mysql).
    How to access the mysql using ordinary command line (or the same simple tool) in my case?

    Hi pvgdrk,
    To get access directly to a mysql database, you can use the commandline tool(open a cmd window-->type mysql the commadline ) or the
    GUI MySQL workbench.
    Since this is a question about MySQL, I would suggest you post your question in a dedicated MySQL forum. You will get more prompt response.
    If you have any feedback on our support, please click
    here.
    Eric Zhang
    TechNet Community Support

  • Making MySQL ORDER BY link dynamic in URL

    I would like to have a dynamic table sorted by a dynamic URL.
    I have found this script but I am not sure where I am meant
    to put the DECLARE?
    This is the MySql recordset:
    BEGIN
    DECLARE @SortOrder tinyint
    SET @SortOrder = 2
    SELECT *
    FROM products
    WHERE `Section` = colname OR `Department` = colname2
    ORDER BY CASE WHEN @SortOrder = 1 THEN Code
    WHEN @SortOrder = 2 THEN Name
    ELSE Order
    END
    I get an error saying this:
    You have an error in your SQL syntax; check the manual that
    corresponds to your MySQL server version for the right syntax to
    use near 'DECLARE @SortOrder tinyint SET @SortOrder = 2 SELECT *
    FROM products WHERE `Sec' at line 2
    Any ideas? And in the script what does the number 2 in this [
    SET @SortOrder = 2 ] refer to? Two CASES?

    I don't know for sure, but one thing I see is that you are using an alias which has the same name as the column:
    DATE_FORMAT(date_created, '%m/%d/%Y %l:%i %p') AS 'date_created',
    Then the order by clause is using that same column/alias. Maybe this is confusing MySQL?  If MySQL supports alias's based on functions in the order by clause, you might want to change that alias name to something else, like date_created_alias and use that in the order by.
    Otherwise, try using the complete function in the order by clause:
    ORDER BY DATE_FORMAT(date_created, '%m/%d/%Y %l:%i %p')  DESC
    But in any case, it sure seems like it should be sorting correctly the way you are currently handling it.

  • Installing mysql:sudo launchctl: command not found

    After several days of reading about:
    Installation of MySQL
    Enabling apache server
    And getting phpMyAdmin up
    I have run into an obstacle.  See error message below **
    I am Running:
    'Mountain lion' , 'Mac OS X 10.8.3'
    I have downloaded:
    MySQL version. Mac OS X 10.7. (X86, 64-bit), DMG Archive.
    Within this forum I found a very brief but helpful 'user tip' post.
    Link1.
    https://discussions.apple.com/docs/DOC-3082
    Where this sentence lead me to believe I could use the version listed above.
    There is NO version for 10.8
    " Download MySQL from a local mirror. You want the Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive. At the time of writing this User Tip, the current version is 5.5.34. By the time you read this, there may be a newer version to use instead. Open the archive mysql-5.5.34-osx10.6-x86_64.dmg. "
    Following the instructions on link1, and all went well until
    I am getting this error message when I type the following command at the terminal prompt:
    **Error message
    -bash: launchctl: command not found.
    1. I cd - changed directories all the way back up the file structure to type the  command
    to see if it needed to be run someplace special but the same error came up.
    2. I searched here on this forum and on the web.
    3. I went back and checked over every step and everything that i typed.
    4. I ended up typing the instructions below by hand
    because somewhere I read that a copy/paste may insert invisible characters.
    Excerpt from link1.
    sudo vi /Library/LaunchDaemons/com.mysql.mysql.plist
    Use the following content:
    <plist version="1.0">
      <dict>
        <key>KeepAlive</key>
        <true/>
        <key>Label</key>
        <string>com.mysql.mysqld</string>
        <key>ProgramArguments</key>
        <array>
        <string>/usr/local/mysql/bin/mysqld_safe</string>
        <string>--user=mysql</string>
        </array>
      </dict>
    </plist>
    Can someone please explain what I am missing ?
    Why is this command
    -bash: launchctl: command not found.
    That is launch c t lowercase L not number 1
    An added note. 
    The following link also had a very nice set of instructions but unlike link1, this link uses the
    'Preference pane' and 'startup item' which link1 discourages because it causes problems down the road.
    I would rather use the command line and do not want to give up on this method.
    Link2.
    http://coolestguidesontheplanet.com/install-configure-apache-mysql-php-phpmyadmi n-osx-10-8-mountain-lion/
    Now that I am going head strong with this project, I hope that my issue can be resolved quickly with this community
    so I don't loose my momentum.
    Thanks a lot.

    1. You are really a nice person.  Thank you.  I really want to understand these file structures.  Sorry my posts are lengthy.
    Thank you for taking the time to look at the original User Tip.
    2. I hope that you do not end this thread when I tell you that I actually have gotten php running.  These concepts are still very important to me.
    I am not up to the point where I am using mySQL so that may end up another troubleshooting problem.
    3. Last week and this I have been exploring my files with terminal by cd-ing  up and down; using sudo nano to open the file to see what is in there.
    I have included some things that may be useful since you have a much better idea about how these paths work.
    4. If you have a chance - Can you elaborate.  I understand a PATH.  What to you mean when you say PATH environmental variable.
    I think of a variable in the computer programmer syntax sense.
    5. I also cannot find a .profile file anywhere. See the below.... where I found something....
    4. Searching like crazy for the load executable.  I cannot find it yet.  I thought that it might be with the  other commands in /bin
    below are some exploratory commands I am running and things I find of interest.
    I use ls -la to display 'all' files. I use -la to list hidden files. those that start with a dotFileName.
    /user/local/mysql/bin
    there is NO load executable here.
    I looked around for 'load'
    macBookPro: /shortname$  ls
    cd bin
    ls -la
    lots of commands:  launchctl  mkdir  pwd  echo ....   i thought that 'load' should live here.
    cd etc
    ls -la
    has:apache2  my.conf  named.conf  passwd paths php.ini sudoes nanorc
    apache2 empty - title: new buffer
    sudoers  i have questions about this but not a priority now.
    nanorc
    php.ini
    my.conf
    name.conf
    passwd
    paths
    sudo nano paths
    /usr/bin
    /bin
    /usr/sbin
    /sbin
    /usr/local/bin
    I did not find the .profile file. what I have found is the below which references the .profile for sh(1)
    I am unable to interpret the below file/code - well maybe a little.
    cd etc
    ls -la 
    sudo nano profile
    # System-wide .profile for sh(1)
    if [ -x /usr/libexec/path_helper ]; then
            eval `/usr/libexec/path_helper -s`
    fi
    if [ "${BASH-no}" != "no" ]; then
            [ -r /etc/bashrc ] && . /etc/bashrc
    fi
    Here is
    /usr/sbin
    sudo nano apachectl
    the following is the code in apachectl
    I see 'run launchctl load ....'
    LAUNCHCTL="/bin/launchctl"
    LAUNCHD_JOB="/System/Library/LaunchDaemons/org.apache.httpd.plist"
    run_launchctl() {
        if [ $UID != 0 ]; then
            echo This operation requires root.
            exit 1
        fi
        $LAUNCHCTL $@
    # Set the maximum number of file descriptors allowed per child process.
    if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
        $ULIMIT_MAX_FILES
    fi
    ERROR=0
    if [ "x$ARGV" = "x" ] ; then
        ARGV="-h"
    fi
    case $ARGV in
    start)
        run_launchctl load -w $LAUNCHD_JOB
        ERROR=$?
    stop|graceful-stop)
        run_launchctl unload -w $LAUNCHD_JOB
        ERROR=$?
    restart|graceful)
        run_launchctl unload -w $LAUNCHD_JOB 2> /dev/null
        run_launchctl load -w $LAUNCHD_JOB
        ERROR=$?
    startssl|sslstart|start-SSL)
        echo The startssl option is no longer supported.
        echo Please edit httpd.conf to include the SSL configuration settings
        echo and then use "apachectl start".
        ERROR=2
    configtest)
        $HTTPD -t
        ERROR=$?
    status|fullstatus)
        echo Go to $STATUSURL in the web browser of your choice.
        echo Note that mod_status must be enabled for this to work.
        $HTTPD $ARGV
        ERROR=$?
    esac
    exit $ERROR
    Thanks again for helping me to understand these file structure.
    There is no preview option so i hope this posts well.

  • Understanding order of commands in RMAN script

    I just started working at a new job and the prior DBA had already left before I got there. I'm looking at his RMAN script to backup the 11gR2 single instance database and I can't understand what is the need for two "crosscheck backup" commands? Wouldn't it be prudent to also have a "crosscheck backup of archivelog all" command as well? Also, what is the point of having the "restore database preview" command in the daily backup script?
    run
    crosscheck backup;
    recover copy of database with tag 'ORA$OEM_LVL1_ILANDB_PRIM' until time 'SYSDATE-1';
    backup incremental level 1 for recover of copy with tag 'ORA$OEM_LVL1_ILANDB_PRIM' database plus archivelog delete all input;
    delete noprompt obsolete;
    restore database preview;
    crosscheck backup;
    }

    Here is how RMAN is currently configured. How do you suggest I clean this up?
    RMAN> show all;
    using target database control file instead of recovery catalog
    RMAN configuration parameters for database with db_unique_name ORCL are:
    CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
    CONFIGURE BACKUP OPTIMIZATION ON;
    CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
    CONFIGURE CONTROLFILE AUTOBACKUP ON;
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/app/oracle/fast_recovery_area/ORCL/fullbackup/full_bkp_${DD}/%F';
    CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 4;
    CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
    CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
    CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u02/app/oracle/fast_recovery_area/ILANDB/fullbackup/full_bkp_%d_DB_%u_%s_%p';
    CONFIGURE MAXSETSIZE TO UNLIMITED; # default
    CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
    CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
    CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
    CONFIGURE EXCLUDE FOR TABLESPACE 'WEBTASK_DATA';
    CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
    CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_ORCL.f'; # default

  • MySQL socket problems after system update

    I have been using my new Mac Mini Snow Leopard server as Squeezebox Server for over a month wihtout problems. After a system update this weekend I started to get MySQL socket errors after reboot.
    Started; log sequence number 0 43655
    091213 17:10:04 [ERROR] Can't start server : Bind on unix socket: Invalid argument
    091213 17:10:04 [ERROR] Do you already have another mysqld server running on socket: /Users/admin/Library/Caches/Squeezebox/squeezebox-mysql.sock ?
    091213 17:10:04 [ERROR] Aborting
    Although I have posted this issue to the Squeezebox forum (http://forums.slimdevices.com/showthread.php?t=72510) where it primarily belongs to I wanted to hear if anyone maybe had an idea what recent changes in Apple updates could cause this? Maybe someone else has similar MySQL problems with other installations? I am a bit desperate by now so any idea or hint is appreciated.

    Here was my solution/workaround for this issue to the rest of us poor fellas that have too fight around with Squeezebox server from time to time:
    I setup SBS to use the the standard MySQL installation on Mac OS X SL Server since I could get it to run without problems from Server Admin. Here are the instruction from the SBS Wiki:
    http://wiki.slimdevices.com/index.php/ExistingMySQLInstance
    However, I had to deviate a bit from that in order to make it work since it seems a bit outdated.
    First deviation was necessary for the MySQL access privileges. Notice the extra grant to slimserver@localhost. Don't ask me why but this worked. I do also not know whether both grants would be necessary because I haven't tried it. Feel free to improve it:
    # mysql -u admin_user -p
    Enter password: admin_password
    Welcome to the MySQL monitor.
    Commands end with ; or \g.
    Your MySQL connection id is 103 to server version: 5.0.24a-log
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    mysql> create database slimserver;
    Query OK, 1 row affected (0.22 sec)
    mysql> grant all on slimserver.* to slimserver identified by 'slimserver_password';
    Query OK, 0 rows affected (0.13 sec)
    mysql> grant all on slimserver.* to slimserver@localhost identified by 'slimserver_password';
    Query OK, 0 rows affected (0.13 sec)
    mysql> flush privileges;
    Query OK,
    mysql> quit
    There were also slight differences necessary in the preferences setup because MySQL socket location was different from the standard one. Here are my db entries ~/Library/Application Support/Squeezebox/server.prefs:
    dbpassword: slimserver_password
    dbsource: dbi:mysql:database=slimserver;mysql_socket=/var/mysql/mysql.sock
    dbusername: slimserver
    Notice the extra mysql_socket configuration.

  • Mysql socket error 2002

    I've read all about this error and have played around with it for a while and still can't get it to work. This is how I got to where I am.
    1. installed OS X Server fresh and updated to 10.4.7
    2. installed entrophy php 5.1.4 from the installer pkg
    3. installed mysql standard 5.0.22 from the installer pkg
    4. installed phpMyAdmin and am trying to browse to http://localhost/phpMyAdmin/index.php and am getting the socket error 2002
    I read the technote http://docs.info.apple.com/article.html?artnum=302977 which refers to the mysql.sock file.
    when I start up mysql, it says 'running' and the mysql.sock file is in /var/mysql/ my php.ini file is pointing there. the /etc/my.conf file is pointing there.
    yet I'm still getting this error.
    What am I missing?

    At this point, you have two versions of PHP and two versions of MySQL installed on your system. So, when you say you start up MySQL, how are you doing that?
    For a MySQL-package installed version, you need to start up MySQL in the path /usr/local/mysql/bin/... or use the StartupItem they provide, which would be "/Library/StartupItems/MySQLCOM/MySQLCOM start". Then check where the mysql.sock file is with "/usr/local/mysql/bin/mysqladmin -u root variables" (or "/usr/local/mysql/bin/mysqladmin -u root -p variables", if you've given your root user a password so far).
    Also, you can check your PHP installation's default MySQL socket file search path with "/usr/local/php5/bin/php -i" and see what the "MYSQL_SOCKET" variable states is the location for the MySQL socket file.
    You just have to make sure these two things are in sync in order to get something like phpMyAdmin to run.
    NOTE: If you just type "php" or "mysql" at the command line, you're going to be launching/using Apple's preinstalled versions, so you'll always need to use the full path when working on the command line.

  • Mysql.sock does not exist!

    I'm trying to set up mysql. So I went and installed phpmyadmin and it set up without any errors. But when I go to log into it, it gives me error #2002 Cannot log into mysql server. I read that this was because it couldn't access mysql.sock, and sure enough it was looking for the file in /var/mysql/mysql.sock
    Unfortunatly for me, the directory /var/mysql does not exist. I thought I would try to install a later version from mysql.com, but it told me to stop all other instances of mysql with this command. I ran that command, and it said "Cannot connect to local MySQL server through socket '/var/mysql/mysql.sock'" !!!!!
    I could go ahead and try to install a new version of MySQL, but it said it would install the sock file in this other folder. (/tmp/mysql.sock) If I do that, I would have to change a bunch of config files to point to this new location, and I don't really know what things need that and what things don't. (I'm kindof new to server management)
    So my question is: Why is mysql.sock not in /var/mysql/ and how do I get it there? I ran locate "mysql.sock" and it returned no results.
    I'm using the stock versions of everything on Mac os X server 10.6.5

    How a server is secured depends on the local configuration and requirements.
    Blocking access to this particular tool might involve putting the tool on a separate Site on a different IP port and not passing that port through the firewall, or blocking access to the tool via rewrite rules, or setting up an http-level password.
    [Here is one thread on this topic|http://stackoverflow.com/questions/2631269/how-to-secure-phpmyadmin], or [here|http://www.phpbuilder.com/board/showthread.php?t=7109220], and particularly see the last part of the [phpMyAdmin Official Quick Install documentation|http://www.phpmyadmin.net/documentation>.
    There are some specific recommendations in the phpMyAdmin tool, including +You should deny access to the ./libraries and ./setup/lib subfolders in your webserver configuration. For Apache you can use supplied .htaccess file in that folder, for other webservers, you should configure this yourself. Such configuration prevents from possible path exposure and cross side scripting vulnerabilities that might happen to be found in that code.+
    I've seen all manner of access attempts and injection attacks attempted against that tool, too; there was a barrage of attempts earlier today on one of my servers.
    And FWIW, I tend to use the command line tools, or the Sequel Pro tool.

  • MySQL - how can I change an IP address restriction for a user [solved]

    I'm getting "Host ... is not allowed to connect to this MySQL server" when attempting to connect to mysql.  I read this guide which gives a solution but I have no idea how to physically implement the solution.
    You can fix this by setting up an account for the combination of client host name and user name that you are using when trying to connect.
    I want to change the access from "localhost" to any address on my LAN (192.168.0.*) for user facade, but am unsure of the proper syntax.
    # mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 53
    Server version: 5.5.16-log Source distribution
    Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    mysql> select host, user from mysql.user;
    +-----------+--------+
    | host | user |
    +-----------+--------+
    | 127.0.0.1 | root |
    | ::1 | root |
    | localhost | facade |
    | localhost | root |
    +-----------+--------+
    4 rows in set (0.00 sec)
    Last edited by graysky (2011-10-18 23:37:54)

    Host can be a combination of IP/netmask. In your case, something like:
    UPDATE mysql.user SET host = '192.168.0.0/255.255.255.0' WHERE user = 'facade'

  • [solved] akonadi does not have mysql db

    Hi,
    I noticed that my akonadi logs keeps telling me that
    091022  8:55:18 [Warning] Can't open and lock time zone table: Table 'mysql.time_zone_leap_second' doesn't exist trying to live without them
    091022  8:55:18 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
    I connected to the askonadi mysqld socket and looked at the db's. it didnot have a mysql db.
    jithine ~ $ mysql -S /home/jithine/.local/share/akonadi/db_misc/mysql.socket -u jithine
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 11
    Server version: 5.1.39-log Source distribution
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    mysql> show databases;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | akonadi |
    +--------------------+
    2 rows in set (0.00 sec)
    mysql> Bye
    jithine ~ $ mysql -S /home/jithine/.local/share/akonadi/db_misc/mysql.socket -u root
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 12
    Server version: 5.1.39-log Source distribution
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    mysql> show databases;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | akonadi |
    +--------------------+
    2 rows in set (0.00 sec)
    mysql>
    Has anyone noticed this. How is it working w/o mysql database.
    In the .local/share/akonadi/mysql.conf I can see that the settings have been repeated 3 times
    Last edited by jithin1987 (2009-12-09 00:06:41)

    I also get the same error message. Did you find any solution?
    Edit: Solved
    http://forum.kde.org/viewtopic.php?f=20&t=83092
    mysql_install_db --datadir=$HOME/.local/share/akonadi/db_data/
    Last edited by axel (2009-12-08 22:16:03)

  • JAVA and MYSQL NOW() Function only displays year?

    I have run into something interesting with running the MYSQL NOW() function.
    Here is what I'm running:
    SELECT  NOW() from databaseThis gives me "2010" only. Any idea why this may be? If I run the same mysql query in mysql from the command line I get the correct output "2010-01-14 14:10:03".
    Has anyone else seen this behavior?
    Edited by: crusherdestroyer on Jan 14, 2010 12:19 PM

    I'm not doubting that. Here is how I'm using it.
    import java.util.Date;
    String userName = "username";
                   String password = "password";
                   String url = "jdbc:mysql://localhost/database";
                   Class.forName ("com.mysql.jdbc.Driver").newInstance ();
                   conn = DriverManager.getConnection (url, userName, password);
                   //System.out.println ("Database connection established");
                   Statement s = conn.createStatement ();
                   s.executeQuery ("SELECT NOW() from database' ");
                   ResultSet rs = s.getResultSet ();
                   int count = 0;
                   Date timenow = null;
                   while (rs.next ())
                       timenow = rs.getDate ("NOW()");
                    ++count;
    System.out.println (timenow);Tried this too.
    String userName = "username";
                   String password = "password";
                   String url = "jdbc:mysql://localhost/database";
                   Class.forName ("com.mysql.jdbc.Driver").newInstance ();
                   conn = DriverManager.getConnection (url, userName, password);
                   //System.out.println ("Database connection established");
                   Statement s = conn.createStatement ();
                   s.executeQuery ("SELECT NOW() from database' ");
                   ResultSet rs = s.getResultSet ();
                   Date timenow = null;
                       timenow = rs.getDate ("NOW()");
    System.out.println (timenow);Edited by: crusherdestroyer on Jan 14, 2010 2:04 PM
    Edited by: crusherdestroyer on Jan 14, 2010 2:07 PM

  • Entering data into a mySQL database for use with my JDBC program

    does any know what i type on telnet to get mySQL to work on windows 2000?
    i read check your isp for what to type in for this line, but i use IIS
    www24:mywww/devshed# mysql -u devshed -p
    and what do i put for
    login: devshed
    Password: ********
    it says check with isp on that one too
    i am trying to insert records, and make columns, is there an easier way to do this?
    thanks,
    Pearl
    Beginning MySQL Tutorial
    By W.J. Gilmore
    April 03, 1999
    Part 1: At First Glance
    MySQL is most commonly entered through telnet. (A nice Telnet program, Easyterm, can be found at http://www.arachnoid.com) Once the telnet connection to the web server has been accomplished, a second command provides access to the MySQL server. The procedure to make these connection is as follows:
    1. Connect to telnet. This involves the insertion of the given ISP username and password.
    --------------------------------------------------------------------------------login: devshed
    Password: ********
    Last login: Wed Aug 12 09:49:14 from 195.103.124.222
    Copyright 1992, 1993, 1994, 1995, 1996 Berkeley Software Design, Inc.
    Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
    The Regents of the University of California. All rights reserved.
    BSDI BSD/OS 2.1 Kernel #12: Mon Feb 23 13:46:27 EST 1998
    You have new mail.
    www24:mywww/devshed#
    2. Connect to MySQL. This involves the insertion of the username and password given specifically for MySQL use. This information has probably been provided to you at your request to the ISP provider.
    --------------------------------------------------------------------------------www24:mywww/devshed# mysql -u devshed -p--------------------------------------------------------------------------------
    Syntax: mysql -h hostname -u username -p[password]
    Or
    mysql -h hostname -u username --password=password
    The user will then be prompted for a password, as prompted by -p.
    --------------------------------------------------------------------------------Enter password: *******--------------------------------------------------------------------------------
    Assuming MySQL has been correctly installed and configured, the user will see output similiar to the following:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 49 to server version: 3.21.23-beta-log
    Type 'help' for help.
    mysql>
    (Note: If an error message pertaining to "Access denied" is the result of connection attempts, you should consult the MySQL documentation included with the software, the MySQL mailing list found at http://www.mysql.com, as well as your ISP provider. These resources will aid greatly in resolving these problems.)
    Once connected to the database, we are free to execute the various commands of the MySQL language. However before we are able to modify the database, we must first connect to it, via the command:
    --------------------------------------------------------------------------------mysql> use devshed;
    Result:
    --------------------------------------------------------------------------------Database changed
    Mysql>
    You now are connected to the database. Note that the command was followed by a semi-colon (;). Almost all commands in MySQL are followed by a semi-colon.
    At the disposition are a number of administrative commands. These commands can be viewed simply by typing help, \h or ? at the command line:
    --------------------------------------------------------------------------------mysql> help
    help (\h) Display this text
    ? (\h) Synonym for `help'
    clear (\c) Clear command
    connect (\r) Reconnect to the server. Optional arguments are db and host
    edit (\e) Edit command with $EDITOR
    exit (\) Exit mysql. Same as quit
    go (\g) Send command to mysql server
    print (\p) print current command
    quit (\q) Quit mysql
    rehash (\#) Rebuild completion hash
    status (\s) Get status information from the server
    use (\u) Use another database. Takes database name as argument
    Connection id: 49 (Can be used with mysqladmin kill)
    mysql>

    Let's make this simple:
    a) Your book seems to assume you're doing development remotely.
    b) You are not doing development remotely.
    c) Therefore, you shouldn't follow every step listed in your book (i.e. ignore the stuff about Telnet).
    Assuming you installed mySQL in the standard location, you can use this batch file to start mySQL on your machine:
    @echo on
    cd c:\mysql\bin
    mysqld
    @echo off
    cls
    Use this batch file to shut down mySQL:
    @echo on
    cd c:\mysql\bin
    mysqladmin shutdown
    @echo off
    cls
    You can play around without a login or password in development. For a production environment, you're going to need to set up users and grant permissions.
    Spend some time reading the mySQL documentation.

  • JDeveloper/MySql: 'access denied'

    I'm trying to develop a web application using JDeveloper/MySql...
    My 'try-out' servlet ends here:
    conn = DriverManager.getConnection("jdbc:mysql://localhost/eyes?user=me&password=pwd");
    saying
    "Access denied for user 'me'@'localhost.localdomain' (using password: YES) 11045 228000"
    user me has been granted 'all' and the database eyes is accessible via the commandline.
    Any help is appreciated!

    This is MySQL issue not JDeveloper.
    Anyway this problem usually occurs when:
    1. there is not localhost or hostname in "user" table (mysql).
    So check whether user table contains two rows for user, one row for "localhost" and the second row for hostname or single row where "%" (any host) is in hostname column.
    Example:
    mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1810 to server version: 4.1.5-gamma-standard
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    mysql> \u mysql
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    Database changed
    mysql> select * from user where user = 'test2';
    | Host      | User  | Password         | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections |
    | localhost | test2 | 35a7d8163f9d93b2 | Y           | Y           | Y           | Y           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                |          |            |             |              |             0 |           0 |               0 |
    | machinename  | test2 | 35a7d8163f9d93b2 | Y           | Y           | Y           | Y           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N          | N            | N          | N                     | N                | N            | N               | N                |          |            |             |              |             0 |           0 |               0 |
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------2. common mistake is when user is created and privileges granted and administrator didn't flush hosts and privileges.
    So login as root and execute "flush hosts" and "flush privileges" commands.
    Example:
    mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 1812 to server version: 4.1.5-gamma-standard
    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
    mysql> flush hosts;
    Query OK, 0 rows affected (0.00 sec)
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)

  • MySQL & PHP issues since upgrade

    Little bit of background: I ran an arch server about two years ago, basically a personal web server (for about a year).  Had apache, mysql and php running nicely on it using the basic configurations with some minor changes.
    Now, present day.  I have recently installed Arch again and once the upgrades were announced, I held off on installing the LAMP applications.  So, Friday I installed them (as oppsed to upgrading), and thought I had them all working fine.  Apache was running, mysql was running (command line access was working well with one exception, more on that later), and php was being parsed.  When I tried to pull data out of a database, i was getting "call to undeclared function mysql_pconnect()."  I googled the error and searched the Arch forums, and everything said to make sure php was compiled with the '--with-mysql' option.  I checked that using phpinfo(), and indeed it was, but it was '--with-mysql=/shared', /usr' (or something similar).  What I ended up doing was removing the arch package and recompiling php myself using '--with-mysql' (no arguments) and it works beautifully.  So, basically, is the arch configuration for php correct?
    Also, issue number two, I have created a non-root user in mysql, but when i try to log in i receive access denied for 'user@localhost' (using password: YES).  Did i miss a setting that won't allow me to log in as anyone but root?
    Thanks in advance. 

    simple, edit your php.ini like so:
    BEFORE:
    1250:;extension=mysql.so
    AFTER
    1250:extension=mysql.so
    no need to recompile php.
    ps: "grep -n mysql.so /etc/php.ini"

  • Php/mysql: can't write to mysql database [SOLVED]

    I'm writing a login script using php and mysql. I got it to work on my server about a week ago, and then I set up apache, php and mysql on my netbook so that I could take my code with me and test it. Now it doesn't work. My registration script doesn't write to the mysql database but has no errors. Here is register.php:
    <?php
    define("DB_SERVER", "localhost");
    define("DB_USER", "root");
    define("DB_PASS", "swordfish");
    define("DB_NAME", "users");
    define("TBL_USERS", "users");
    $connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error());
    mysql_select_db(DB_NAME, $connection) or die(mysql_error());
    function addUser($username, $password)
    global $connection;
    $password = md5($password);
    echo("adding $username,$password<br />");
    $q = "INSERT INTO " . TBL_USERS . " VALUES ('$username', '$password')";
    echo("query: $q<br />");
    $result = mysql_query($q, $connection);
    echo("$result<br />");
    if (isset($_POST["reg"]))
    addUser($_POST["username"], $_POST["password"]);
    echo("<a href='index.php'>click here to login</a>");
    ?>
    <html>
    <head>
    <title>Register</title>
    </head>
    <body>
    <form method="Post" name="login">
    <input type="text", name="username" /> Username<br />
    <input type="text", name="password" /> Password<br />
    <input type="submit" name="reg", value="Register" />
    </form>
    </body>
    </html>
    and here is the output (without the form):
    adding lexion,6f1ed002ab5595859014ebf0951522d9
    query: INSERT INTO users VALUES ('lexion', '6f1ed002ab5595859014ebf0951522d9')
    Also, I tried manually adding the content to the database:
    $ mysql -p -u root
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 9
    Server version 5.1.42 Source distribution
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    mysql> users
    -> INSERT INTO users VALUES('lexion', 'foo')
    -> ^D
    -> Bye
    I would assume that I got something wrong with the last bit, but the php script seems like it should work. Does anybody know why it doesn't?
    Last edited by Lexion (2010-01-10 19:04:15)

    What is wrong with your PHP? Why do you think it is failing? An INSERT query doesn't return anything. Also, it's a good idea to specify which fields you are inserting into, unless you want to have to provide something for every field (tedious for tables with many fields with default values). eg:
    $q = "INSERT INTO `" . TBL_USERS . "`(`username`, `password`) VALUES ('$username', '$password')";
    As for your experiment with the mysql prompt; queries have to end with a semicolon. PHP is nice and hides that little detail from you.
    edit: Also, you're echoing text out before the HTML starts. That won't produce valid HTML. I also noticed a few other things which I corrected; look at my comments:
    <?php
    define("DB_SERVER", "localhost");
    define("DB_USER", "root");
    define("DB_PASS", "swordfish");
    define("DB_NAME", "users");
    define("TBL_USERS", "users");
    $connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error());
    mysql_select_db(DB_NAME, $connection) or die(mysql_error());
    function addUser($username, $password)
    global $connection;
    $password = md5($password);
    // echo("adding $username,$password<br />"); - Don't echo stuff before HTML starts.
    // Also, clean up user-supplied data before plugging it into a query unless you want to be vulnerable to SQL injection.
    $cleanusername = mysql_real_escape_string($username, $connection);
    $cleanpassword = mysql_real_escape_string($password, $connection); // Obviously you'd generally use some hashing algorithm like md5 or sha1 for passwords
    $q = "INSERT INTO `" . TBL_USERS . "`(`username`, `password`) VALUES ('{$cleanusername}', '{$cleanpassword}')"; // The backticks tell MySQL not to interpret any text within as a keyword (good for field names, eg a field called `date`. The curly brackets tell PHP that the stuff within refers to a variable; it's nice as PHP knows exactly what the variable name is with no possible ambiguity.
    // echo("query: $q<br />");
    $result = mysql_query($q, $connection);
    // echo("$result<br />"); - This won't do anything; in addition to INSERT queries not returning anything, the $result variable doesn't contain the results of the query, it's a pointer to them for use with mysql_result().
    ?>
    <html>
    <head>
    <title>Register</title>
    </head>
    <body>
    <?php
    if (isset($_POST["reg"]))
    addUser($_POST["username"], $_POST["password"]);
    echo("<a href='index.php'>click here to login</a>");
    ?>
    <form method="Post" name="login">
    <input type="text" name="username" /> Username<br />
    <input type="text" name="password" /> Password<br />
    <input type="submit" name="reg" value="Register" />
    </form>
    </body>
    </html>
    <?php
    mysql_close($connection); // Not strictly needed, as PHP will tidy up for you if you forget.
    ?>
    Last edited by Barrucadu (2010-01-10 17:34:20)

Maybe you are looking for